So I have a site sitting on URL "mysite.com" and another site on "subdomain.mysite.com". User accounts are stored in "mysite.com", so when I need to log in on "subdomain.mysite.com" I take the user to "mysite.com", they enter their credentials authenticate them normally and make sure that the authentication cookie is usable in "subdomain.mysite.com" by setting the domain
in the cookie as follows:
HttpCookie cookie = FormsAuthentication.GetAuthCookie(username, true);
cookie.Domain = ".mysite.com";
Response.Cookies.Add(cookie);
Then I redirect them back to "subdomain.mysite.com" and the user is thankfully authenticated there.
Everything works well except when logging out. When the user tries to log out from any site, I remove the authentication cookie as expected:
FormsAuthentication.SignOut();
But for some reason the cookie is not being removed, the user stays logged in.
I have tried deleting the cookie directly using Request.Cookies[FormsAuthentication.FormsCookieName]
but still nothing. Chrome is holding on to the cookie really tight for some reason: I can see it in Chrome's developer tools.
What am I doing wrong? Help!