close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Resetting cart after worldpay transaction - VERY URGENT NOW

Thread began 11/29/2011 2:47 pm by Base5 Designs | Last modified 11/29/2011 9:35 pm by Base5 Designs | 1173 views | 2 replies |

Base5 Designs

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.....

Sign in to reply to this post

Jason ByrnesWebAssist

your code does not look quite right. use this code instead.

it should go on the success page after the closing </html> tag

php:
<?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 (ini_get("session.use_cookies")) {
    
$params session_get_cookie_params();
    @
setcookie(session_name(), ''time() - 42000,
        
$params["path"], $params["domain"],
        
$params["secure"], $params["httponly"]
    );
}

// Finally, destroy the session.
session_destroy();
@
session_start();
@
session_regenerate_id(TRUE);

@
session_start();
//Reset the UserID Session Variable
if(isset($UserID) && $UserID != "") {
$_SESSION['UserID'] = $UserID;

if(isset(
$UserGroupID) && $UserGroupID != "") {
$_SESSION['UserGroupID'] = $UserGroupID;
}
session_commit();
?>
Sign in to reply to this post

Base5 Designs

works perfectly Jason thanks very much, made me a very happy man.

I realised after reading your reply that i had been trying to add the code on the response page and not the success page and now is working great.

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...