Currently, after 10 days or so after cleaning up my /tmp/cook directory, there are 3657 session files

vm645:/tmp/cook# ls | wc -l
3657

so I assumed they're not cleaned up itself.

Snippet of my php.ini

session.save_path = "/tmp/cook"
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =

so I assume it should be cleaned automatically. I think this one is also related with cleaning up

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; http://php.net/session.gc-maxlifetime
session.gc_maxlifetime = 1440
session.gc_probability = 0
session.gc_divisor = 1000

am I missing something? What do I need set in order to force PHP clean up that directory after a while (but not to kill live sessions?)

My PHP version is PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40)

link|improve this question

What version of PHP are you using? If it's not at least 4.2.3, you should upgrade. Otherwise, PHP relies on atime updates, which may not happen. – David Schwartz Sep 20 '11 at 13:14
PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40) – genesis Sep 20 '11 at 13:16
How about the session.gc_probability and session.gc_divisor? – quanta Sep 20 '11 at 13:23
@quanta updated it – genesis Sep 20 '11 at 13:25
feedback

1 Answer

up vote 1 down vote accepted

The probability that a session will get cleaned up is equal to session.gc_probability / session.gc_divisor (with the exception that it'll never get cleaned up until session.gc_maxlifetime has passed); the short version is that you need to make session.gc_probability non-zero.

Docs are here.

link|improve this answer
Perfect, I'll look tomorrow and tell you how does it work – genesis Sep 20 '11 at 13:35
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.