Possible Duplicate:
How do I expire a PHP session after 30 minutes?
I am destroying all session var in logout.php and calling it when user click on logout, what is user does not click on logout.php but directly close the browser. how can i delete session then???
You can set an expiration time for the session data, test it with each session_start
call and destroy the session if it’s expired:
session_start(); if (!isset($_SESSION['EXPIRES']) || $_SESSION['EXPIRES'] < time()+3600) { session_destroy(); $_SESSION = array(); } $_SESSION['EXPIRES'] = time() + 3600;
You cannot. However, session cookies are usually sent without an expire time which means they are deleted when the browser is closed, so the session is lost anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With