The idea is that you want to start a new session with a new session ID.
you could store some session variables into application variables, destroy the session, then reset them in the new session. For example, if the users login is tracked by a session variable name UserID:
<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
@session_start();
//store the UserID Session Variable
if(isset($_SESSION['UserID']) && $_SESSION['UserID'] != "") {
$UserID = $_SESSION['UserID'];
}
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (isset($_COOKIE[session_name()])) {
@setcookie(session_name(), '', time()-42000, '/');
}
// Finally, destroy the session.
session_destroy();
@session_start();
//Reset the UserID Session Variable
if(isset($UserID) && $UserID != "") {
$_SESSION['UserID'] = $UserID;
}
?>