views:

111

answers:

3

when I create a cookie for a domain, is it possible for me to set that this domain should be on both the www and non www domain?

I check for a cookie, and if not present I rediret to login page (its not a super secure thing). it seems when the user has a cookie, if the url changes to www. it gets redirected to login again.

+3  A: 

When you drop the cookie specify .mydomain.com - note the leading period. That should work for both the root domain and the www subdomain.

+1  A: 

@electronherders' solution works, but you should also consider canonicalising either the www or the no-www domain. Redirect visitors from one to the other, so there's only one correct URL for your site.

ceejayoz