Jump to content

multiple domains vs. subfolders: session variables


Pacopag

Recommended Posts

Suppose I have two versions of the same website; one American and one Canadian.  This site has members with profiles etc.  The way my site is written, I think that if someone were to login to their account on, say, the American site, then a session variable would indicate that a user is logged in on the client machine.  Now if they visit the "profile" page, for example, or some other members-only page ON THE CANADIAN SITE, and start manipulating data etc., then this would affect the databases for the Canadian site, and everything would get screwed up (actually, I think mysql would just start spitting out errors, but that's not good either).

 

Does anyone have some simple way to deal this this kind of thing?  I don't really know exactly how session variables work.  Say I have two domains, somepage.com and somepage.ca on the same server/DNS.  If a page on somepage.com sets a session variable called $_SESSION['somevar'], and a page on somepage.ca also sets a variable called $_SESSION['somevar'], are the two variables somehow distinct because they are on different domains?  Like, if somepage.com sets the variable, then somepage.ca check if the variable is set, what will happen?  What if I wanted to set up the two pages in subfolders, like somepage.com/us and somepage.com/ca, how would I deal with distinguish session variables for the two sites?  Is one approach (i.e. distinct domains vs subfolders) better than the other?

 

Thanks,

Link to comment
Share on other sites

By default two different applications can not share a session, so setting a session variable on one domain cannot be used on another domain to access information regardless of whether they have the same variable name set or not. Sessions are domain specific.

Link to comment
Share on other sites

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.