my php.ini:
session.gc_probability = 100
session.gc_divisor = 100

my code(ss.php):

ini_set("session.gc_maxlifetime", 30);
ini_set("session.cookie_lifetime", 360024365*10);

session_start();
if ($SESSION['alive']) {
echo 'alive';
}else {
$
SESSION['alive'] = 'alive';
echo 'dead';
}

I run ss.php first time , prints 'dead', then run ss.php 2nd time prints 'alive'
but run ss.php 3rd time after 30s or more long time ,it still prints 'alive'
and the expired session file are not deleted

I thought gc will execute every request(100%), but it does not work as I expected

OS: WinXP Professional (SP2)
WWW: Apache
Filesystem: FAT32

    The assumption in your code would be that session_start() does the garbage collection before it registers the session for the current script. If the inverse is true (I don't know if it is), then you would need to have a second user agent access the script more than 30 seconds after the last access by the first user agent, then access it from the first user agent again.

      Write a Reply...