stale session files

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
With all the security concerns and folks disabling JavaScript and  
cookies I converted my site to PHP. Originally I use session cookie to  
keep track of items our patrons selected on our gallery for checkout.  
Since the cookie was just in the clients browser memory, garbage  
collection was simple. Now with PHP sessions, patrons now do not have to  
have cookies enabled to shop on our site, but since this is not a 'log  
on' and 'log off' situation there is not an explicit 'log off' event to  
destroy the session. The stale sessions files pile up. Is my only option  
create a maintenance script to run periodically to delete session file >  
24hrs old?

Take care,

Re: stale session files

No, there is a garbage collector that will clear out old session files.
Every time a session starts it is (by default) 1 percent chance that it
will be run.
In php.ini
session.gc_probability = 1
session.gc_divisor     = 100

Change this if you like. But it will also add some extra work to the
engine if you have high rate of visitors ( = collector runs too often).
If you want a neat session handling it's quite useful to take a look at
and store session data in a database. It will give you much more
control over the data.

Site Timeline