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? 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] 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. 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". 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. 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
Archived
This topic is now archived and is closed to further replies.