5kyy8lu3 Posted August 14, 2009 Share Posted August 14, 2009 Hi. Like the title states, I noticed that sessions are sensitive to the url. If I load my site as www.example.com and start a session, I can't access the session variables if I open the same page in a new browser window if I visit the page as http://example.com. is there any way to get it so it doesn't matter which way the site is accessed? it's not super important but it irks me. example 1: I open www.example.com in one browser window, then log in. then in a new window i open www.example.com. it shows "logged in." but if I open a third window and visit the site but I type it without the "www." in the url, it doesn't find the session and shows not logged in. this works vice versa too. any ideas? Link to comment https://forums.phpfreaks.com/topic/170226-solved-sessions-httpwwwexamplecom-vs-httpexamplecom/ Share on other sites More sharing options...
5kyy8lu3 Posted August 14, 2009 Author Share Posted August 14, 2009 Hi. Like the title states, I noticed that sessions are sensitive to the url. If I load my site as www.example.com and start a session, I can't access the session variables if I open the same page in a new browser window if I visit the page as http://example.com. is there any way to get it so it doesn't matter which way the site is accessed? it's not super important but it irks me. example 1: I open www.example.com in one browser window, then log in. then in a new window i open www.example.com. it shows "logged in." but if I open a third window and visit the site but I type it without the "www." in the url, it doesn't find the session and shows not logged in. this works vice versa too. any ideas? ok I found my own solution lol. i have an IF statement that checks to see if $_SERVER['SERVER_NAME'] has "www" in it or not. if not, header() to the address with "www" included. not pretty or elegant but it works. now i know that it won't matter which way the address is typed because my script forces it to be one way. Link to comment https://forums.phpfreaks.com/topic/170226-solved-sessions-httpwwwexamplecom-vs-httpexamplecom/#findComment-897951 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.