[nycphp-talk] Session timing out too soon
jellicle at gmail.com
Thu Dec 4 09:31:31 EST 2008
On Thursday 04 December 2008, Aaron Fischer wrote:
> I have an application built for internal use that has a user login and
> then uses sessions to track their state. I am running into a problem
> in that their session seems to expire if they are on one page for
> somewhere between 15-25 minutes. This creates a big problem because
> they type up a long report, submit it and then get booted out of the
> application without the report being saved.
> I would like to have the user be able to be logged in for a full eight
> hour day, regardless of their level of activity.
> How would I do this? I would appreciate any suggestions. Also of
> note, I am in a shared hosting environment.
This one has been asked before. The default lifetime for sessions is 24
minutes. However, in a shared environment, the default lifetime is the
lowest of any user's choice; so if one user on the shared server has the
default lifetime set to 1 minute, EVERYONE'S sessions expire after one
minute (more or less; read up on how session files are randomly deleted).
Because PHP can't tell the difference between that user's session files and
your session files, they're all in the same common directory.
So. What you need to do is specify your own directory for your session
files (/sharedserver/myroot/mysessionfiles/), and then set the cleanup
lifetime to whatever you want (session.gc_maxlifetime).
Here's an explanation with some sample code:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the talk