Page 1 of 1
Automatically Session expires
Posted: Thu Sep 20, 2007 3:28 am
by vinoth
Hi,
I have some trouble with sessions. I wrote a
login-srcipt based on sessions. It works fine. But now
I want that after ten minutes of inactivity the users
are automatically logged out. But I don't know how to
realize it. I am using PHP 5.
Can someone help me?
Thanks in advance,
Vinoth
Posted: Thu Sep 20, 2007 3:35 am
by s.dot
Logged out... or to have the session expire?
To have the session expire, set the session.gc_max_lifetime in your php.ini file to 600 seconds (10 minutes). You can also be able to do this with
ini_set().
If you want to do it with the code, you could store the time() in the session on each page load and compare it to the current time() on a subsequent page load.
Posted: Thu Sep 20, 2007 9:57 am
by feyd
It's suggested to use the
time() based method instead of trying to get the garbage collection system to do it for you.
Posted: Fri Oct 26, 2007 7:43 am
by vinoth
How we control the session expires through time() function.
I didnot got your suggesstion please explain in detail
Posted: Fri Oct 26, 2007 9:29 am
by feyd
The time() based method places the management responsibility in your code. Specifically, you store a timestamp in their session data. You check this timestamp against the current timestamp.. If your logic considers it expired, then your code would delete the session data and log out the user bringing them back to a default, browsing state.
Re: Automatically Session expires
Posted: Wed Feb 13, 2008 1:35 am
by vinoth
Sorry For late reply.
I check the time stamps for 1 hour but anyway the session expires after 14 minutes.
Is any possible way to prevent the session expires after 14 minutes or untill we close the browser.