I know a cookie can be shared across multiple subdomains using the setting
<forms
name=".ASPXAUTH"
loginUrl="Login/"
protection="Validation"
timeout="120"
path="/"
domain=".mydomain.com"/>
in Web.config. But how to replicate same thing on local machine. I am using windows 7 and IIS 7 on my laptop. So I have sites localhost.users/ for my actual site users.mysite.com
localhost.host/ for host.mysite.com and similar.
localhost.usersandlocalhost.hostis cross domain. Cookies cannot be shared cross domain.You could configure it like this so that the sub-domain differs but the root domain stays the same:
users.localhosthost.localhostNow set the cookie domain in your web.config to
localhost:and in your
c:\Windows\System32\drivers\etc\hostsfile add the following 2 entries:Now you will be able to successfully share the authentication cookie between
users.localhostandhost.localhost.Ah, and don’t forget to put a step in your automated build process that will transform your web.config value to the correct root domain before shipping in production.