MAPG-185 switch off builtin session gc

This commit is contained in:
Bence Pőcze 2020-07-05 16:48:37 +02:00
parent 0bcb0187c1
commit b2e09c394b
Signed by: bence
GPG Key ID: AA52B11A3269D1C1
2 changed files with 4 additions and 12 deletions

View File

@ -71,17 +71,8 @@ class DatabaseSessionHandler implements ISessionHandler
public function gc($maxlifetime): int public function gc($maxlifetime): int
{ {
$select = new Select(\Container::$dbConnection, 'sessions'); // empty on purpose
$select->columns(['id']); // old sessions are deleted by MaintainDatabaseCommand
$select->where('updated', '<', (new DateTime('-' . $maxlifetime . ' seconds'))->format('Y-m-d H:i:s'));
$result = $select->execute();
while ($session = $result->fetch(IResultSet::FETCH_ASSOC)) {
$modify = new Modify(\Container::$dbConnection, 'sessions');
$modify->setId($session['id']);
$modify->delete();
}
return true; return true;
} }

View File

@ -67,7 +67,8 @@ if (isset($_COOKIE['COOKIES_CONSENT'])) {
session_set_save_handler(Container::$sessionHandler, true); session_set_save_handler(Container::$sessionHandler, true);
session_start([ session_start([
'gc_maxlifetime' => 604800, 'gc_maxlifetime' => 604800,
'cookie_lifetime' => 604800, 'gc_probability' => 0, // old sessions are deleted by MaintainDatabaseCommand
'cookie_lifetime' => 604800, // TODO: cookie is not renewed so session can be lost
'cookie_httponly' => true, 'cookie_httponly' => true,
'cookie_samesite' => 'Lax' 'cookie_samesite' => 'Lax'
]); ]);