Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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)

share|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

1 Answer 1

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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