I am running a test and live site on the same server. They have separate DB’s and live in separate directories, but are both on the same domain. As the code is the same, so are the variable names, so if I have pages from both environments open at once the values get shared. How can I isolate my $_SESSION variables to its own distinct environment?
Asked
Active
Viewed 77 times
-1
-
consider adding your code example. – Talk is Cheap Show me Code Nov 12 '19 at 05:50
-
https://stackoverflow.com/questions/1027732/preventing-session-conflicts-in-php – Lkbhai Lr Nov 12 '19 at 06:13
2 Answers
4
give your session a name before starting it
session_name('PROJECT1');
session_start();

Amado
- 371
- 1
- 16
-
https://stackoverflow.com/questions/1027732/preventing-session-conflicts-in-php – Lkbhai Lr Nov 12 '19 at 06:14
0
you can use $_SERVER['HTTP_HOST'] variable to check which request is currently being served and then put condition of session variable using $_SERVER['HTTP_HOST']
like this
if($_SERVER['HTTP_HOST'] == "abc.com"){
}

bharat savani
- 339
- 5
- 18
-
https://stackoverflow.com/questions/1027732/preventing-session-conflicts-in-php – Lkbhai Lr Nov 12 '19 at 06:13