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.