LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PHP session.gc_maxlifetime (https://www.linuxquestions.org/questions/programming-9/php-session-gc_maxlifetime-251569/)

j-ray 11-05-2004 02:54 PM

PHP session.gc_maxlifetime
 
hi,
as u may know session.gc_maxlifetime is a variable determined in php.ini that sets the interval for the garbage collection to remove unused stuff after a given time.
Does it remove all session variables older than this amount of time or does it remove only those variables and directories that have not been touched for the time? If u know for sure plz gimme an answer or a hint where to find reliable info.
thanks a lot
j.

mgatny 11-07-2004 01:45 PM

By default, PHP stores sesssion information on the filesystem. Each session has one file containing serialized session variables.

When the GC runs, it loops through the entire directory where the session files reside. For each session file, the filesystem mtime is subtracted from the current time, and if this amount of time is greater than session.gc_maxlifetime, the session file is deleted.

In other words, accessing an 'expired' (i.e. according to the lifetime you specified) session stored in a particular directory will cause other 'expired' session files in that directory to be cleaned up as well. Therefore, be careful when modifying the session.gc_maxlifetime. You may want to give your script its own session.save_path so that you do not unintentionally clobber other sessions.


All times are GMT -5. The time now is 03:59 PM.