Resetting cart after worldpay transaction - VERY URGENT NOW
Hi there
I keep mentioning this issue, with my other post's but it keeps geting ignored so here it is on its own.
After a sucsessfull worldpay transaction my response page is showing all the correct information, but my session values ARE NOT GETTING CLEARED.
So the cart remians full, and they have to clear the cart manually.
i've looked on the forums for solutions to clearing the data afer a succsessfull transaction and am implementing the following code:
<?php
//WA eCart Include
require_once($_SERVER['DOCUMENT_ROOT'] . "/WA_eCart/eCart1_PHP.php");
?>
<?php
$eCart1->GetContent();
?>
<?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'];
}
if(isset($_SESSION['UserGroupID']) && $_SESSION['UserGroupID'] != "") {
$UserGroupID = $_SESSION['UserGroupID'];
}
// 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;
}
if(isset($UserGroupID) && $UserGroupID != "") {
$_SESSION['UserGroupID'] = $UserGroupID;
}
session_commit();
?>
his code is not working as expected...
The cart is not empty, when a user clears the cart manually and makes a new order, the response page and emails are showing the data from the last order, even though the worldpay transaction shows the values for the new order.
I am certain this is because he session_id is stored in the database and so when the new order is made it is not creating a new order reference. because the session~_id is not changing.
I need a fix to this urgently.
I even tried creating a seperate page with the above code and link on my response page to go to this and then have that clear the session, then redirect to my index page and that does not work either.
Please can you provide me with a working solution for clearing the data after a worldpay transaction, preferably keeping the users details in tact.
$_SESSION['UserID'] and $_SESSION['UserGroupID']
I have promised my client the site would be ready to go live on the 1st of december.....