Re: Destroying session data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this might be coming into play:
http://us4.php.net/session

session.gc_maxlifetime  integer

    session.gc_maxlifetime specifies the number of seconds after which
data will be seen as 'garbage' and cleaned up.


Okay, lemme see if I understand how it works. Even if it "sees" it as garbage, it will not destroy it until the session has ended? or will destroy when that time is reached? So can I set session.gc_maxlifetime to be a low number (e.g., 10 seconds) and it will still behave appropriately? Currently, it's set to the default - 1440.

~Philip

There are two parts to it:

session.gc_lifetime = 10
(any session data which is older than this is considered "garbage" by PHP's garbage collector)


session.gc_probability = 1
session.gc_divisor = 1
(these two combine to calculate the probability that PHP will check for and clean up "garbage" when it starts up)


So if you *always* wanted to destroy every session after 10 seconds you can use the settings above. But just realize that this will prevent users from storing anything long term on the server. Not only that but you'll have overhead on every PHP script because you'll end up destroying session files on every startup.

Perhaps cron / scheduled tasks is a better answer for you? Just create a script that destroys all files in the session directory and run it as often as you like.


-- Teach a person to fish...

Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux