title: 'session state is not available in this context' when multiple files in request
body: <p>The code sample at <a href="http://support.microsoft.com/kb/2527105" rel="nofollow">http://support.microsoft.com/kb/2527105</a> is exactly what I need to share sessions between two subdomains.  Only problem is it doesn't work in a real life situation.  It works fine when the ony file being requested is the page itself, but throws an error 'session state is not available in this context' when other files are part of the request, such as if I add stylesheets or javascript files to the page.  The code is generating this error in the "if (context.Session != null &amp;&amp;" line below:</p>
  
  <pre><code>void context_PostRequestHandlerExecute(object sender, EventArgs e)
  {
      HttpApplication context = (HttpApplication)sender;
      HttpCookie cookie = context.Response.Cookies["ASP.NET_SessionId"];
  
      if (context.Session != null &amp;&amp;
          !string.IsNullOrEmpty(context.Session.SessionID))
      {
          cookie.Value = context.Session.SessionID;
          if (rootDomain != "localhost")
          {
              cookie.Domain = rootDomain;
          }
          cookie.Path = "/";
      }
  }
  </code></pre>