close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

sessionid not clearing

Thread began 7/23/2011 2:26 am by CraigR | Last modified 7/25/2011 4:16 pm by Ray Borduin | 1133 views | 5 replies |

CraigRBeta Tester

sessionid not clearing

i notice this when testing several transactions in succession.

if i make a successful transaction my sessions are cleared and the cart is emptied. However, if i add more items to the cart and make a second purchase very soon afterwards, the session_id which is stored in the orders table as Orderreferenceid is the same as the previous one.

Sign in to reply to this post

Ray BorduinWebAssist

You should be able to add code to the top of your checkout success page to regenerate the session id:

<?php
session_regenerate_id();
?>

Sign in to reply to this post

CraigRBeta Tester

Hi Ray.

I already have the folowing code at the bottom of my checkout success page.

php:
<?php 
//initialize the session
if (!isset($_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'/');
}
 
// Finally, destroy the session.
@session_destroy();//This will also clear the session cookie which forces a new session ID to be generated.
?>



Just wondered why sessionid was stil intact after this point, as the cart content is cleared

Sign in to reply to this post

Ray BorduinWebAssist

session_destroy will remove all session variables, but won't actually regenerate the session id.

If you want to remove all variables from session and change SID first use

session_regenerate_id();
session_destroy();

if you do destroy first then regenerate_id your SID will not change.

I found this on the php site: function.session-destroy.php

Sign in to reply to this post

CraigRBeta Tester

Thanks Ray.

My client has now decided they don't want the customer to be logged out after a successful transaction.

Whats the easist way to retain the accountid session whilst clearing the rest.

Sign in to reply to this post

Ray BorduinWebAssist

Probably save it before clearing the session, then clear the session and then re-set it:

<?php
$LoginID = $_SESSION['UserID']

session_regenerate_id();
session_destroy();

session_start();
$_SESSION['UserID'] = $LoginID;
?>

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