Session not being completed killed after checkout
When a customer completes their purchase they are direct to the checkout_success page and the session is at least partially cleared. By that I mean the cart is empty but I am finding that if a customer makes a second purchase sooner after that the OrderReferrenceID is not cleared and I am getting multiple orders with the same OrderReferrenceID but different OrderID's. This is not only a potential issue in general in the database but it is also causing issue with my shipping warehouse. Below is the current code to clear the session on the checkout_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();
?>