How to clear a session without cleaning other parts of the site

It's hard to explain it, but here. I found a similar question in the search, but it was for C, not PHP.

I am developing a PHP site that has two sections for logging in, one for employees and one for employers. When the user logs out, their session is cleared, currently using the "session_destroy ()" function. I also use this on the login page to clear any previous session.

The problem arises if I work on both sections at the same time. Because they are on the same "site", entering one magazine from another. I have to use two browsers at a time, one went to one section and the other to another.

Is there a better way to end a session when a user logs out rather than "session_destroy ()", which will not affect another part of the site?

+4
source share
2 answers

You can save site session data in another part of the session:

$_SESSION['site1'] = ... ; 
$_SESSION['site2'] = ... ;

and then call unset in a session that you no longer want:

unset($_SESSION['site1']);
+3
source

you will delete a specific session

     unset($_SESSION['variable']);

the variable will be the value of the user / administrator session

+2
source

All Articles