[pmwiki-users] short sessions

Patrick R. Michaud pmichaud at pobox.com
Tue Mar 8 19:19:42 CST 2005


On Tue, Mar 08, 2005 at 06:43:38PM -0500, Radu wrote:
> Problem:
> When I stay for a bit longer in the edit window (either editing a long page 
> or talking on the phone), after I press save I get to the password window. 
> It goes ahead with the read passw, which means that somehow the session 
> expired while I was away. Pm mentions somewhere that the php environment 
> might be at fault. So a phpinfo says, among other things:
> 
> Session Support enabled
> session.cache_expire 180 180
> session.cookie_lifetime 0 0
> session.entropy_length 0 0
> session.gc_divisor 100 100
> session.gc_maxlifetime 1440 1440
> 
> Does anyone know where the problem might be?

That last variable says that the maximum time for a session is 1440
seconds, or 24 minutes.  So, if you go for more than 24 minutes without
interacting with the server,  your session may timeout.

On some shared hosting services, things can get a little weird.  
There's a "bug" (or at least a misfeature) in PHP that sessions are
all stored in a shared directory, and any PHP script can clean up the
sessions left over from any other PHP script.  Unfortunately, this
means that a PHP script that sets a shorter session.gc_maxlifetime
can cause sessions from other scripts to expire sooner.  (Personally
I think each session file should have a timestamp that says when the
session will expire, but the PHP designers didn't do it that way.)

So, if you're on a server where some script gets executed that sets
a shorter gc_maxlifetime, your sessions may get cleaned up earlier
than you expect.

The "solution" is to set a custom value for session.save_path that
points to a unique location for your sessions.  However, I'm not 
exactly sure how that affects the cleaning up of session files -- I'm
still looking into that.  (I know of at least one instance where
setting a custom session.save_path is causing the session files to
not be removed.)

Pm



More information about the pmwiki-users mailing list