title: sharing session data between domains in asp.net, confused!
body: <p>Ok, here's my problem, i want to maintain session data between two applications or domains (eg:- www.abc.com  and secure.abc.com).</p>
  
  <p>I have read on net about this, but many people pointing many different ways to do it, with people commenting +ve and -ve responses to all. Plus many are just providing theoretical answer, do this and that ,but no code at all.</p>
  
  <p>are these steps all that is required?
  1) in web.config: <code>&lt;httpCookies domain=".abc.com"/&gt;</code></p>
  
  <p>2) store session data in sql DB as:(after preparing the db for storing sessions)</p>
  
  <pre><code>&lt;sessionState mode="SQLServer" sqlConnectionString="Data Source=YourServer;
  Integrated Security=True;database=MySessionDB" sqlCommandTimeout="30" 
  allowCustomSqlDatabase="true"/&gt;
  &lt;machineKey decryption="AES" validation="SHA1" decryptionKey="..." validationKey="..." /&gt;
  </code></pre>
  
  <p>3)Am confused about this one: i want to set the domain for the session cookie like this
  Response.Cookies["ASP.NET_SessionId"].Domain = ".abc.com";
  But where should this code be written?
  this entry: <a href="http://mgrzyb.blogspot.com/2007/12/aspnet-and-subdomains.html" rel="nofollow noreferrer">http://mgrzyb.blogspot.com/2007/12/aspnet-and-subdomains.html</a> says: use System.Web.SessionState.SessionIDManager  as a base class but the SaveSessionID method is not virtual so cannot be overridden. Options are: either explicitly re-implement the interface method or decorate SessionIDManager class and after calling SessionIDManager.SaveSessionID  set Response.Cookies[SessionIdCookieName].Domain  to our domain.</p>
  
  <p>Only if the author had provided real code, step 3 would have been clear.</p>
  
  <p>Can anyone provide the code for it.</p>
  
  <p>Plus all this 3 steps enough to share session among the domains?</p>