I’m currently working with an application where I’m facing an obvious problem. There are two major panels in my application one is the admin panel and the other is the user panel as obvious.
Suppose, the admin currently logs in into his panel and the same time some users on the user panel may have already logged in. What happens, if I’m using the following code in PHP to log out and redirect to the log in page (when either the admin or any of the users logs out).
session_start();
session_unset();
if(session_destroy())
{
header("location:Login.php");
}
Let’s assume that a user is logging out while the admin still logs in. The above code will destroy the session and consequently, the admin will also log out and redirected to the log in page.
I know session can be unset something like this unset($_SESSION['something']) but it’s a tedious process to remember all the session variables used in the application as there are so many session variables have already been used in both the sides (admin and user).
Is there a way to destroy the admin session and the user session separately? I mean when a user logs out his session is destroyed that must not affect the admin session at all and vice verse.
Sessions are independent between users. Just because one user logs out doesn’t mean that every single session is destoryed – just the user’s who logged out.