I have 2 sites.
In one site this is true:
session_is_registered('site1sess')
and in the other one this is true:
session_is_registered('site2sess')
Those are the session names I give users on login. My problem is that when I logout from one site, I also logout in the other one because I use:
session_destroy();
What is the best way to logout from site1 or 2 deleting all the session variables from it? Thank you.
Destroying a PHP Session A PHP session can be destroyed by session_destroy() function. This function does not need any argument and a single call can destroy all the session variables. If you want to destroy a single session variable then you can use unset() function to unset a session variable.
The process is: - Click Log In button on index. php - Enter username and password to access authenticate index file. - Click log out button, which references the logout. php file - it SHOULD clear the cache and return the user to the top level index.
Use unset()
for all the session variables specific to either site 1 or 2.
unset($_SESSION['site1']);
//or
unset($_SESSION['site2']);
Just so that you know, session_is_registered
is deprecated as of PHP version 5.3.0. See docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With