feat: improve session loading

This commit is contained in:
grandeljay 2023-12-19 12:49:12 +01:00
parent 5295cbc7e1
commit b36621d767

View file

@ -261,7 +261,7 @@ class User
); );
$database->connect(); $database->connect();
$session = $database $sessions = $database
->query( ->query(
'SELECT * 'SELECT *
FROM `sessions` FROM `sessions`
@ -270,18 +270,20 @@ class User
'session' => $_COOKIE['wishthis_session'], 'session' => $_COOKIE['wishthis_session'],
) )
) )
->fetch(); ->fetchAll(\PDO::FETCH_ASSOC);
if (false === $session) { if (false === $sessions) {
return false;
}
if (\strtotime($session['expires']) <= \time()) {
return false; return false;
} }
foreach ($sessions as $session) {
if (\strtotime($session['expires']) > \time()) {
return true; return true;
} }
}
return false;
}
/** /**
* Returns a list of the users wishlists. * Returns a list of the users wishlists.