I am building a site in asp.net and have multiple subdomains. For example, one.cookies.com two.cookies.com
I want my users to be able to login at either subdomain and be logged in for both websites. In addition, I’d like the sessions and cookies to be in sync. So far I haven’t found a reliable way to do this.
When you create the cookie you can set the domain:
This will allow your cookie to be accessible from all subdomains of cookies.com.
If you are using FormsAuthentication then you can set the domain for the auth cookie in web.config:
Remember that for the single sign-on to work on multiple subdomains your ASP.NET applications must share the same machine keys as explained in this CodeProject article.
Sharing sessions between different subdomains (different worker processes) is more difficult because sessions are constrained to an application and you will have to implement a custom session synchronization mechanism.