views:

92

answers:

2

If I type http://example.com and login to my site and close my browser, re-open it and retype http://example.com then I am logged in.

However, when I type http://example.com, login, close the browser, re-open it, type http://www.example.com then I am NOT logged in.

I do not use ASP .NET authentication classes.
I run IIS 6 with both example.com and www.example.com URLs added to "Multiple identities for this web site" in IIS.

I do not wish the current behavior. Are there other things that can be affected because of this behavior?

+1  A: 

Please make sure from your domain panel that it is referring to same IP Address and code. I was having same issue and found that IP Address was different.

jalpesh
Name Type Data, A 89.38.215.221,cp A 89.38.214.101,ftp A 89.38.214.141,mail A 89.38.209.22,www A 89.38.215.221,MX [10], mail.cupacupelor.ro,NS ns1.livehosting.info,NS ns2.livehosting.info,TXT v=spf1 a mx -allI have these
pixel3cs
A: 

The problem is that you can't share cookies between example.com and www.example.com, due to a quirk in the cookie specification.

Instead, what you should do is pick one of the domains as your primary. Then, detect references to the other domain, and redirect users from there back to the primary. For example, you could choose www.example.com as the primary, and redirect references to example.com back to www.example.com.

That way, the authentication cookies will be present if the user tries to switch from one domain to another.

RickNZ
public static void AddForFirstTime(string nickname, string guid) { HttpCookie cookie = new HttpCookie(LoginCookie.CookieName); cookie.Values["nickname"] = nickname; cookie.Values["guid"] = guid; cookie.Values["action"] = "login"; cookie.Expires = DateTime.MaxValue; HttpContext.Current.Response.Cookies.Add(cookie); }this is all what I do with cookies
pixel3cs
Answer updated...
RickNZ