Jump to content

[SOLVED] Sessions: http://www.example.com VS http://example.com


5kyy8lu3

Recommended Posts

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?

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.