Mutley Posted June 25, 2008 Share Posted June 25, 2008 Not sure what is causing it but I have a login system, When I goto www.mysite.com, and login, then goto http://mysite.com it asks me to login again? How do I make it so the URL prefix isn't an issue? Quote Link to comment https://forums.phpfreaks.com/topic/111902-cookies-different-with-http-and-www/ Share on other sites More sharing options...
Jabop Posted June 25, 2008 Share Posted June 25, 2008 Put this in your .htacess Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^site.com [NC] RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301] Quote Link to comment https://forums.phpfreaks.com/topic/111902-cookies-different-with-http-and-www/#findComment-574395 Share on other sites More sharing options...
ober Posted June 25, 2008 Share Posted June 25, 2008 Show us the code you're using ... you can set the domain in your cookies. Quote Link to comment https://forums.phpfreaks.com/topic/111902-cookies-different-with-http-and-www/#findComment-574419 Share on other sites More sharing options...
thebadbad Posted June 25, 2008 Share Posted June 25, 2008 Yeah, if you're not setting the domain in your cookie, it defaults to the domain where it's set. And http://mysite.com isn't the same domain as http://www.mysite.com. To make the cookie available on all subdomains, set the domain as ".mysite.com". Quote Link to comment https://forums.phpfreaks.com/topic/111902-cookies-different-with-http-and-www/#findComment-574443 Share on other sites More sharing options...
roopurt18 Posted June 25, 2008 Share Posted June 25, 2008 I never noticed you could set the domain when setting a cookie so I usually fixed this with a redirect to a domain starting with www. Is either of these methods better than the other. Initially, I'd have to say the redirect is preferred because the user might browse to http://domain.com and then click on a link pointing to http://www.domain.com. Not a problem for the cookies, but if you have JavaScript in each page that needs to access objects in the other you will have problems there. Quote Link to comment https://forums.phpfreaks.com/topic/111902-cookies-different-with-http-and-www/#findComment-574493 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.