Forum Moderators: coopster

Message Too Old, No Replies

problem with the sessions' garbage collector

php 4.4.0

         

tata668

1:57 am on Oct 7, 2005 (gmt 0)

10+ Year Member



I use a custom session handler to store the sessions in a database. I use "session.gc_probability = 100" in php.ini for testing purpose.

My problem: the "session_gc_method" method, the method that garbage collects the expired sessions, is called two times for each page! It is called at session_start() and at the end of the output...

Am I missing something here? Shouldn't this method be called only at session_start()?

tata668

4:07 pm on Oct 7, 2005 (gmt 0)

10+ Year Member



Please? :-(

coopster

6:06 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



We'll assume that the "session_gc_method" you refer to here is your user-defined garbage collection routine in your own session_set_save_handler() [php.net] function definition. There is a note on that page regarding how the "write" handler works that you may want to double check.

tata668

6:28 pm on Oct 10, 2005 (gmt 0)

10+ Year Member



Thanks for your reply coopster..

I found my problem and I feel really stupid now! ;-)

I used the code here [zend.com]

Look at the "_close" function: it calls the gc function! I just removed this and now everything is fine.

coopster

6:31 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Don't be calling yourself stupid now as you will be labeling us all -- we've all been there and will likely be there again ;) Glad you got it sorted.