Wednesday, 7 July 2010

ASP.NET SESSION STATE, COOKIES AND SUBDOMAINS

  1. protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
  2. {
  3. /// only apply session cookie persistence to requests requiring session information
  4. #region session cookie
  5. if (Context.Handler is IRequiresSessionState || Context.Handler is IReadOnlySessionState )
  6. {
  7. /// Ensure ASP.NET Session Cookies are accessible throughout the subdomains.
  8. if (Request.Cookies["ASP.NET_SessionId"] != null && Session != null && Session.SessionID != null)
  9. {
  10. Response.Cookies["ASP.NET_SessionId"].Value = Session.SessionID;
  11. Response.Cookies["ASP.NET_SessionId"].Domain = ".know24.net"; // the full stop prefix denotes all sub domains
  12. Response.Cookies["ASP.NET_SessionId"].Path = "/"; //default session cookie path root
  13. }
  14. }
  15. #endregion
  16. }

No comments:

Post a Comment