Destroying a session...
Posted: Tue Jun 10, 2003 2:21 pm
I thought this would work, but it doesn't. Hence... I am here, asking for help from helpful people.
I want to destroy a session, but keep 2 session variables. Basically, clean out 20+ session variables, and start over with the same user. Problem is that the user info is stored in sessions. I'd like to avoid unsetting that many variables. I know that's not too much work, but I'd like to understand how to do things better.
Is what I'm trying to do, possible? Other than just unsetting all the variables I don't want to keep?
Thanks in advance.
I want to destroy a session, but keep 2 session variables. Basically, clean out 20+ session variables, and start over with the same user. Problem is that the user info is stored in sessions. I'd like to avoid unsetting that many variables. I know that's not too much work, but I'd like to understand how to do things better.
Code: Select all
$UserName = $_SESSION['UserName'];
$UserID = $_SESSION['UserID'];
session_unset();
session_destroy();
$_SESSION['UserName'] = $UserName;
$_SESSION['UserID'] = $UserID;Thanks in advance.