[英]How to maintain session between two sub domain?
如何維護子域之間的會話。
httpCookies domain =“。site.com”
FTP中的“我的文件夾”結構
site1>主站點一個網站project.app_code,bin,web.config
Folder Subdomain1. here i have all files like bin,app_code,web.config etc.
Folder Subdomain2. here also same.
任何人都可以給我一個想法,如何維護這些子域之間的會話。
使用它,我希望它對您有用。
protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
{
/// only apply session cookie persistence to requests requiring session information
#region session cookie
if (Context.Handler is IRequiresSessionState || Context.Handler is IReadOnlySessionState )
{
/// Ensure ASP.NET Session Cookies are accessible throughout the subdomains.
if (Request.Cookies["ASP.NET_SessionId"] != null && Session != null && Session.SessionID != null)
{
Response.Cookies["ASP.NET_SessionId"].Value = Session.SessionID;
Response.Cookies["ASP.NET_SessionId"].Domain = ".know24.net"; // the full stop prefix denotes all sub domains
Response.Cookies["ASP.NET_SessionId"].Path = "/"; //default session cookie path root
}
}
#endregion
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.