How can I share a session across multiple subdomains in ASP.NET?

You tagged this with ASP.NET and IIS, so I will assume that is your environment. Make sure you have this in your web.config:

<httpCookies domain=".usa.com"/>

If your 2 subdomains map to the same application, then you are done. However, if they are different applications you will need to do some additional work, like using a SQL Server based Session storage (and hacking the stored procedures to make sure all applications share the same session data) or with an HttpModule to intercept the application name, since even with shared cookies and the same machine key, 2 applications will still use 2 different stores for their session data.

Leave a Comment