close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

retain some session values after checkout

Thread began 3/24/2015 1:03 pm by CraigR | Last modified 3/26/2015 9:48 am by Jason Byrnes | 825 views | 5 replies |

CraigRBeta Tester

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:
<?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:
<?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);?>
Sign in to reply to this post

Jason ByrnesWebAssist

that should work. I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post

CraigRBeta Tester

PM

Sign in to reply to this post

Jason ByrnesWebAssist

i fixed this by adding:
session_regenerate_id();

after reseting the sessions.

Sign in to reply to this post

CraigRBeta Tester

Awesome, thanks Jason

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...