retain some session values after checkout
I have a checkout success page with a standard code block at the end to destroy the session values
<?php
//initialize the session
session_start();
// 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, '/');
}
// regenerate the session id
//http://www.webassist.com/forums/showthread.php?p=105930#post105930
session_regenerate_id();
// Finally, destroy the session.
@session_destroy();//This will also clear the session cookie which forces a new session ID to be generated.
session_start();
?>
Most pages on this internal site are admin access only, so I want to retain the session values created when the admin user (or superadmin) logs in, via admin_cms/user_login.php
what i have tried to do is simply store the session values as php variables before destroying the session, then reset the session values afterwards, but it doesn't seem to be working,
<?php
//initialize the session
session_start();
//store login session values before destroying session
$superadminlogin = $_SESSION["SuperAdminLogin"];
$adminlogin = $_SESSION["AdminLogin"];
$userid = $_SESSION['UserID'];
$usergroupid = $_SESSION['UserGroupID'];
$contentgroup = $_SESSION['ContentGroup'];
$userfname = $_SESSION['UserFirstName'];
$userlname = $_SESSION['UserLastName'];
// 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, '/');
}
// regenerate the session id
//http://www.webassist.com/forums/showthread.php?p=105930#post105930
session_regenerate_id();
// Finally, destroy the session.
@session_destroy();//This will also clear the session cookie which forces a new session ID to be generated.
session_start();
//restore login session values
$_SESSION["SuperAdminLogin"] = $superadminlogin;
$_SESSION["AdminLogin"] = $adminlogin;
$_SESSION["UserID"] = $userid;
$_SESSION["UserGroupID"] = $usergroupid;
$_SESSION["ContentGroup"] = $contentgroup;
$_SESSION["UserFirstName"] = $userfname;
$_SESSION["UserLastName"] = $userlname;
?>
<?php var_dump($_SESSION);?>