Tutorials All - Webdesign, Graphic Design

Visit our new Webdesign Templates,css,html5 etc

Download New Android Applications

Visit our new Collections of Android Application

4.1.12

Asp.net session state, cookies and subdomains


1.         protected  void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
2.          
3.             {
4.          
5.               /// only apply session cookie persistence to requests requiring session information
6.          
7.          
8.          
9.               #region session cookie
10.        
11.             if (Context.Handler is IRequiresSessionState || Context.Handler is IReadOnlySessionState )
12.        
13.             {
14.        
15.               /// Ensure ASP.NET Session Cookies are accessible throughout the subdomains.
16.        
17.        
18.        
19.               if (Request.Cookies["ASP.NET_SessionId"] != null && Session != null && Session.SessionID != null)
20.        
21.               {
22.        
23.                 Response.Cookies["ASP.NET_SessionId"].Value = Session.SessionID;
24.        




25.                 Response.Cookies["ASP.NET_SessionId"].Domain = ".know24.net"// the full stop prefix denotes all sub domains
26.        
27.                 Response.Cookies["ASP.NET_SessionId"].Path = "/"//default session cookie path root        
28.        
29.               }
30.        
31.             }
32.        
33.             #endregion   
34.        
35.           }