TeddyKiller Posted April 11, 2010 Share Posted April 11, 2010 If I logged in on my site under www.mysite.com I can access any page with the www. though I cant access any page without it. If I logged in on my site under mysite.com I can access any page without the www. Though I cant access any page with it. How can I fix this problem? Quote Link to comment https://forums.phpfreaks.com/topic/198243-sessions-with-and-without-www-problems/ Share on other sites More sharing options...
the182guy Posted April 11, 2010 Share Posted April 11, 2010 Are you manually setting the session ID cookie? Or just using the default session handler? Quote Link to comment https://forums.phpfreaks.com/topic/198243-sessions-with-and-without-www-problems/#findComment-1040135 Share on other sites More sharing options...
TeddyKiller Posted April 11, 2010 Author Share Posted April 11, 2010 The sessions are just set like so.. $_SESSION['uid'] = $row['id']; $hash = sha1($row['id'] . $_SERVER['REMOTE_ADDR'] . $secret_key); $_SESSION['hash'] = $hash; Quote Link to comment https://forums.phpfreaks.com/topic/198243-sessions-with-and-without-www-problems/#findComment-1040136 Share on other sites More sharing options...
PFMaBiSmAd Posted April 11, 2010 Share Posted April 11, 2010 1A) Redirect non-www. addresses to the www. version 1B) Use consistent addresses on all your pages (eliminates unnecessary redirects, see 1A.) 2) You can set the session.cookie_domain setting so that it matches all host-names/sub-domains of your domain. Quote Link to comment https://forums.phpfreaks.com/topic/198243-sessions-with-and-without-www-problems/#findComment-1040144 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.