From 327c1572a4d8971e035e9c24bc49de8e04e4cac0 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Thu, 16 Apr 2026 15:05:20 +0200 Subject: [PATCH] fix session --- application/utils.inc.php | 4 +--- sources/Application/Helper/Session.php | 22 ++++------------------ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index d3c2c434d7..e19f7f18a3 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -284,9 +284,7 @@ class utils } // Read and record the value for switching the archive mode $iCurrent = self::ReadParam('with-archive', $iDefault); - if (Session::IsInitialized()) { - Session::Set('archive_mode', $iCurrent); - } + Session::Set('archive_mode', $iCurrent); // Read and use the value for the current page (web services) $iCurrent = self::ReadParam('with_archive', $iCurrent, true); self::$bPageMode = ($iCurrent == 1); diff --git a/sources/Application/Helper/Session.php b/sources/Application/Helper/Session.php index c17a79a90c..c19f554632 100644 --- a/sources/Application/Helper/Session.php +++ b/sources/Application/Helper/Session.php @@ -21,8 +21,6 @@ class Session /** @var int|null */ public static $iSessionId = null; /** @var bool */ - protected static $bIsInitialized = false; - /** @var bool */ public static $bAllowCLI = false; public static function Start() @@ -31,19 +29,15 @@ class Session return; } - if (session_status() === PHP_SESSION_ACTIVE) { + if (session_status() === PHP_SESSION_ACTIVE || headers_sent()) { // Session already started - self::$bIsInitialized = true; self::$iSessionId = session_id(); return; } - if (!headers_sent()) { - SessionHandler::session_set_save_handler(); - session_name('itop-'.md5(APPROOT)); - } + SessionHandler::session_set_save_handler(); + session_name('itop-'.md5(APPROOT)); - self::$bIsInitialized = true; if (!is_null(self::$iSessionId)) { if (session_id(self::$iSessionId) === false) { session_regenerate_id(true); @@ -55,7 +49,7 @@ class Session public static function RegenerateId($bDeleteOldSession = false) { - if (session_status() === PHP_SESSION_DISABLED) { + if (session_status() === PHP_SESSION_DISABLED || headers_sent()) { return; } @@ -192,14 +186,6 @@ class Session return array_keys($_SESSION); } - /** - * @return bool - */ - public static function IsInitialized(): bool - { - return self::$bIsInitialized; - } - /** * @return bool|string */