Reputation: 12920
I can use Server[request_time] to get current timestamp. But how would I use this on each request so that I know which session hasn't been active for more than 10 minutes? Basically I do not know how to detect these requests so that I can capture the last timestamp(based on that request). Does it have to be attached to every single html button?
Upvotes: 0
Views: 401
Reputation: 3679
You can save the time of the last request in the session:
$_SESSION['last_request'] = time();
You do this on every request.
Before you update the session value, you can check how long the session was inactive:
if (time() - $_SESSION['last_request'] > 10*60) {
echo 'You were inactive for at least 10 minutes.';
}
PS: You can use $_SERVER['REQUEST_TIME']
instead of time()
if you have very long running scrips. In most scenarios it will make no difference.
Upvotes: 1