Fixed session garbage collector

This commit is contained in:
Daniel Maya 2019-08-28 11:33:02 +02:00
parent 21712c5c23
commit 94d797b4b7
1 changed files with 25 additions and 1 deletions

View File

@ -159,7 +159,26 @@ function pandora_session_gc($max_lifetime=300)
global $config;
if (isset($config['session_timeout'])) {
$max_lifetime = $config['session_timeout'];
$session_timeout = $config['session_timeout'];
} else {
// if $config doesn`t work ...
$session_timeout = db_get_value(
'value',
'tconfig',
'token',
'session_timeout'
);
}
if (!empty($session_timeout)) {
if ($session_timeout == -1) {
// The session expires in 10 years
$session_timeout = 315576000;
} else {
$session_timeout *= 60;
}
$max_lifetime = $session_timeout;
}
$time_limit = (time() - $max_lifetime);
@ -171,6 +190,11 @@ function pandora_session_gc($max_lifetime=300)
]
);
// Deleting cron and empty sessions.
$sql = "DELETE FROM tsessions_php WHERE
data IS NULL OR id_session REGEXP '^cron-'";
db_process_sql($sql);
return $retval;
}