cart session not clearing after checkout
after getting the checkout_success.php, I am able to see the cart content.
I guess the checkout process is not clearing the cart session.
how can i fix this?
Thanks in advance...
after getting the checkout_success.php, I am able to see the cart content.
I guess the checkout process is not clearing the cart session.
how can i fix this?
Thanks in advance...
If you are using PHP, add the following at the bottom of the success page:
<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
@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, '/');
}
// Finally, destroy the session.
session_destroy();
?>
is it possible to easily remove the cart items without resetting ALL session variables? This way logs the person out.
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;
}
?>
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
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.