From d1bdc286ba8819400dd9f701208cd98ce0128d02 Mon Sep 17 00:00:00 2001 From: Jay Trees Date: Thu, 10 Mar 2022 09:28:01 +0100 Subject: [PATCH] Remember user after logging in --- index.php | 16 ++++++++++++++++ src/classes/page.php | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 1d49e737..f925d054 100644 --- a/index.php +++ b/index.php @@ -54,8 +54,24 @@ if ( /** * Session */ +$sessionLifetime = 2592000; // 1 Month + +session_set_cookie_params($sessionLifetime, '/'); session_start(); +/** Refresh lifetime */ +$session = session_get_cookie_params(); + +setcookie( + session_name(), + session_id(), + time() + $sessionLifetime, + $session['path'], + $session['domain'], + $session['secure'], + $session['httponly'] +); + /** * API */ diff --git a/src/classes/page.php b/src/classes/page.php index 55da0a05..566e8ff2 100644 --- a/src/classes/page.php +++ b/src/classes/page.php @@ -124,7 +124,11 @@ class Page 'register', 'install' ); - if (!isset($_SESSION['user']) && isset($_GET['page']) && !in_array($_GET['page'], $disableRedirect)) { + if ( + !isset($_SESSION['user']) + && isset($_GET['page']) + && !in_array($_GET['page'], $disableRedirect) + ) { header('Location: /?page=login'); die(); }