Reputation: 155
Difficult to explain this but here goes. I found a similar question in the search but it was for C, not PHP.
I am developing a PHP site which has two logged-in sections, one for employees and one for employers. When either user logs out, their session is cleared, at the moment with "session_destroy()". I also use that at the login page to clear any previous session.
The problem comes if I am working on both sections at the same time. Because they are on the same "site", logging into one logs out of the other. I am forced to use two browsers at a time, one logged into one section and the other into the other.
Is there a better way to end a session when a user logs out rather than "session_destroy()", something that won't affect the other part of the site?
Upvotes: 4
Views: 77
Reputation: 926
you can save each site's session data in a different part of the session:
$_SESSION['site1'] = ... ;
$_SESSION['site2'] = ... ;
and then call unset on the session you don't want any more:
unset($_SESSION['site1']);
Upvotes: 3
Reputation: 3156
you unset a specific session
unset($_SESSION['variable']);
variable will be the user/admin session value
Upvotes: 2