mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
- fix: expired and unremoved session breaks the work
This commit is contained in:
parent
9752d2aa38
commit
85dd42c378
2 changed files with 12 additions and 1 deletions
|
|
@ -42,8 +42,12 @@ class MTTSessionHandler implements SessionHandlerInterface
|
||||||
// read session data if not expired
|
// read session data if not expired
|
||||||
$time = time();
|
$time = time();
|
||||||
$expire = $time;
|
$expire = $time;
|
||||||
$r = $this->db->sq("SELECT data,last_access FROM {$this->db->prefix}sessions WHERE id = ? AND expires >= $expire", [$id]);
|
$r = $this->db->sq("SELECT data,last_access,expires FROM {$this->db->prefix}sessions WHERE id = ?", [$id]);
|
||||||
if ( is_null($r) ) return '';
|
if ( is_null($r) ) return '';
|
||||||
|
if ( (int)$r[2] < $time) {
|
||||||
|
// maybe regenerate id?
|
||||||
|
$r[0] = '';
|
||||||
|
}
|
||||||
|
|
||||||
// update last access time and set expires in 14 days
|
// update last access time and set expires in 14 days
|
||||||
// refresh once in a second
|
// refresh once in a second
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,13 @@ function setup_and_start_session()
|
||||||
ini_set('session.use_cookies', true);
|
ini_set('session.use_cookies', true);
|
||||||
ini_set('session.use_only_cookies', true);
|
ini_set('session.use_only_cookies', true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
After any request we may have 14 days of inactivity (i.e. not requesting session data),
|
||||||
|
then we have to re-login (look at MTTSessionHandler).
|
||||||
|
Activity without re-login lasts for max 60 days, the cookie lifetime, then cookie dies
|
||||||
|
and we have to re-login having new session id.
|
||||||
|
*/
|
||||||
|
|
||||||
$lifetime = 5184000; # 60 days session cookie lifetime
|
$lifetime = 5184000; # 60 days session cookie lifetime
|
||||||
$path = url_dir(Config::get('url')=='' ? getRequestUri() : Config::getUrl('url'));
|
$path = url_dir(Config::get('url')=='' ? getRequestUri() : Config::getUrl('url'));
|
||||||
$samesite = 'lax';
|
$samesite = 'lax';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue