Skip to content
Snippets Groups Projects
Unverified Commit c4669d77 authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #3899 from JediKev/issue/clean-expired-sessions

cron: Delete Expired Sessions
parents acac3707 5a8fdeae
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,11 @@ class Cron {
AttachmentFile::deleteOrphans();
}
function CleanExpiredSessions() {
require_once(INCLUDE_DIR.'class.ostsession.php');
DbSessionBackend::cleanup();
}
function MaybeOptimizeTables() {
// Once a week on a 5-minute cron
$chance = rand(1,2000);
......@@ -100,6 +105,7 @@ class Cron {
self::MailFetcher();
self::TicketMonitor();
self::PurgeLogs();
self::CleanExpiredSessions();
// Run file purging about every 10 cron runs
if (mt_rand(1, 9) == 4)
self::CleanOrphanedFiles();
......
......@@ -158,6 +158,10 @@ abstract class SessionBackend {
return $this->update($id, $i['touched'] ? session_encode() : $data);
}
function cleanup() {
$this->gc(0);
}
abstract function read($id);
abstract function update($id, $data);
abstract function destroy($id);
......@@ -220,6 +224,10 @@ extends SessionBackend {
return SessionData::objects()->filter(['session_id' => $id])->delete();
}
function cleanup() {
self::gc(0);
}
function gc($maxlife){
SessionData::objects()->filter([
'session_expire__lte' => SqlFunction::NOW()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment