Return to Snippet

Revision: 26926
at May 17, 2010 05:24 by tomaszsimon


Initial Code
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    

    }

Initial URL
http://www.know24.net/blog/ASPNET+Session+State+Cookies+And+Subdomains.aspx

Initial Description

                                

Initial Title
ASP.NET Session State, Cookies and Subdomains

Initial Tags

                                

Initial Language
C#