Reputation: 8151
I have a javascript code that basically displays a box that says that you will be logged out within 60 seconds if you dont click on the link. Now my question is can I use that link with a JavaScript onClick event to somehow update my php code that detects if your session is older than 30 mins.
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
// last request was more than 30 minates ago
session_destroy(); // destroy session data in storage
session_unset(); // unset $_SESSION variable for the runtime
header("location:login.php");
}
Short of refreshing the includes.php file is there anything else that I can do to update my $_SESSION['LAST_ACTIVITY'] variable?
Upvotes: 0
Views: 114
Reputation: 1635
you can use session_cache_expire();
and put that before session_start();
Upvotes: 0