If a person idles for 10 minutes then I want the page expired -> user has to login again to continue.
Asked
Active
Viewed 267 times
-5
-
1Possible duplicate of http://stackoverflow.com/questions/3068744/php-session-timeout – Subir Kumar Sao Feb 06 '13 at 09:35
-
1This is very basic and a visit to php.net would solve our problem. – phpalix Feb 06 '13 at 09:37
-
thanx @subirkumarsao for providing me useful link.....thanx buddy ths link wil definitely solve my problem......:) – Ankit Sharma Feb 06 '13 at 09:45
2 Answers
0
session_start();
if( time() - $_SESSION['login_time'] > 600)
{
header("Location:login.php");
}
This will check if the session has been running for more than 600 seconds (10 minutes).
Of course first you have to store:
$_SESSION['login_time'] = time();
when the session is created.

nowhere
- 1,558
- 1
- 12
- 31
-
But Ankit wants session to expire **when user is idle** for 10 mins and not after 10 mins of login. I guess, if your answer is implemented then user will be redirected to login page after 10 mins, no matter user is active or idle. – Bhavik Shah Feb 06 '13 at 09:36
-
mmm yes the title fooled me. In this case i suppose jquery is the only option http://paulirish.com/2009/jquery-idletimer-plugin/ – nowhere Feb 06 '13 at 09:39