MAPG-185 switch off builtin session gc
This commit is contained in:
parent
0bcb0187c1
commit
b2e09c394b
@ -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;
|
||||||
}
|
}
|
||||||
|
3
web.php
3
web.php
@ -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'
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user