NYCPHP Meetup

NYPHP.org

[nycphp-talk] Session Handling

Michael Sims jellicle at gmail.com
Tue Aug 23 09:37:14 EDT 2005


On Tuesday 23 August 2005 00:39, Anirudh Zala (Gmail) wrote:

> php_value session.gc_maxlifetime 7200
>
> But interestingly, this is not working at all and session is seen as
> garbage after it's default timeout period set by php (i.e 24 mins). We
> store session files at default location (i.e under "/tmp") and it
> supports "atime" attribute as well. phpinfo() also shows local value of
> above directive as set to 7200 but session doesn't remain active for that
> amount time and is deleted after 24 hours.
>
> I have noticed on various forums that many ppl have faced this problem,
> and they do not have solution either. Does anyone have any ideas about
> this problem? Or am I missing some more configurations?

You probably have a shared hosting environment, where other websites are 
being hosted on your server too, right?

I think this has even been addressed earlier in this thread, but here it is 
again.  The PHP interpreter doesn't distinguish between sessions pertaining 
to different sites hosted on the same server.  It treats all sessions 
equally, and wipes them out after the specified time period.  So:

Situation A:
--You have session lifetime set high
--Someone else hosted on server has it set to default lifetime
Result: all sessions get wiped after 24 minutes

Situation B:
--You have session lifetime set to 1 minute
--Someone else hosted on server has it set to default lifetime
Result: all sessions get wiped after 1 minute, all other users hosted on 
that server start posting to newsgroups that their sessions are only 
lasting one minute and they don't know what is wrong

I think if you change the session save path to someplace not shared with 
other users (but the webserver has to be able to read and write to it), 
you'll be okay.

Michael Sims



More information about the talk mailing list