Pacopag Posted May 21, 2011 Share Posted May 21, 2011 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, Quote Link to comment https://forums.phpfreaks.com/topic/237021-multiple-domains-vs-subfolders-session-variables/ Share on other sites More sharing options...
dragon_sa Posted May 21, 2011 Share Posted May 21, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/237021-multiple-domains-vs-subfolders-session-variables/#findComment-1218343 Share on other sites More sharing options...
spiderwell Posted May 21, 2011 Share Posted May 21, 2011 subfolders would definately share a session, perhaps have a session variable identifying if they logged in at /us or /ca Quote Link to comment https://forums.phpfreaks.com/topic/237021-multiple-domains-vs-subfolders-session-variables/#findComment-1218352 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.