SithLordKyle Posted August 14, 2008 Share Posted August 14, 2008 I have a login function for my site and have been having session problems lately. I finally narrowed it down and realized that some links are http://mysite.com and some are http://www.mysite.com. When I login at http://mysite.com then move to any folder where the address is http://www.mysite.com, the session gets dropped and I'm not logged in. However, if I take out the www, the session is there. Is there any way to have it encompass both or prevent this from happening? Or should I go through and re-code all the pages so the links point to http://www.mysite.com or http://mysite.com exclusively? Link to comment https://forums.phpfreaks.com/topic/119754-session-drops-from-www-to-no-www/ Share on other sites More sharing options...
genericnumber1 Posted August 14, 2008 Share Posted August 14, 2008 You would have to make the session id be contained in two cookies instead of just one. Changing the links would be simpler. Link to comment https://forums.phpfreaks.com/topic/119754-session-drops-from-www-to-no-www/#findComment-616987 Share on other sites More sharing options...
unkwntech Posted August 14, 2008 Share Posted August 14, 2008 If it's a matter of users going to http://domain.tld instead of http://www.domain.tld then just add a check to the top of the pages. if(!preg_match('www.', $_SERVER['HTTP_HOST'])) { header('Location: http://www.doamin.tld'); } Link to comment https://forums.phpfreaks.com/topic/119754-session-drops-from-www-to-no-www/#findComment-616996 Share on other sites More sharing options...
SithLordKyle Posted August 14, 2008 Author Share Posted August 14, 2008 Thanks! I'll try the second option first, then go back through the code and change out the links. Link to comment https://forums.phpfreaks.com/topic/119754-session-drops-from-www-to-no-www/#findComment-616997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.