diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-10-11 08:06:09 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-10-11 08:06:09 +0300 |
| commit | 451710e9f052db9167afb8130900d2d5bec6993a (patch) | |
| tree | 0a4767754e2df428f066cb20028795dd7d8ab812 /include/sessions.php | |
| parent | 6f771f8b9468f012ba74f2e7d139efe7afbaf321 (diff) | |
| download | the-epube-451710e9f052db9167afb8130900d2d5bec6993a.tar.gz the-epube-451710e9f052db9167afb8130900d2d5bec6993a.tar.xz | |
set missing cookie parameters (samesite & httponly) and fix possible XSS in index_mode via browser URL string
Diffstat (limited to 'include/sessions.php')
| -rw-r--r-- | include/sessions.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/include/sessions.php b/include/sessions.php index 1fa1e2f..b433fb9 100644 --- a/include/sessions.php +++ b/include/sessions.php @@ -6,15 +6,21 @@ $session_name = Config::get(Config::SESSION_NAME); $session_expire = Config::get(Config::SESSION_LIFETIME); - if (Config::is_server_https()) - ini_set("session.cookie_secure", "true"); - ini_set("session.name", "epube_sid"); ini_set("session.use_only_cookies", "true"); ini_set("session.gc_maxlifetime", $session_expire); ini_set("session.cookie_lifetime", "0"); - session_set_cookie_params($session_expire); + // Array signature sets all attributes at once; the legacy scalar form + // silently reset secure/httponly to their defaults. + session_set_cookie_params([ + 'lifetime' => $session_expire, + 'path' => '/', + 'domain' => '', + 'secure' => Config::is_server_https(), + 'httponly' => true, + 'samesite' => 'Lax', + ]); session_save_path(dirname(__DIR__) . "/sessions"); |
