Hi
I have created a session that is running on the web-pages fine. However, the session does not seem to expire when I close the browser. Is there a way to end the session/reset the session variables on a mouse click e.g. clear basket that resets pointers and items in an array?
Thanks
Sessions
Moderator: General Moderators
Re: Sessions
Here is a code you can use on mouse click. It is straight from php manual
Code: Select all
<?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();
?>