fix session

This commit is contained in:
Eric Espie
2026-04-16 15:05:20 +02:00
parent 16cdc80778
commit 327c1572a4
2 changed files with 5 additions and 21 deletions

View File

@@ -284,9 +284,7 @@ class utils
} }
// Read and record the value for switching the archive mode // Read and record the value for switching the archive mode
$iCurrent = self::ReadParam('with-archive', $iDefault); $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) // Read and use the value for the current page (web services)
$iCurrent = self::ReadParam('with_archive', $iCurrent, true); $iCurrent = self::ReadParam('with_archive', $iCurrent, true);
self::$bPageMode = ($iCurrent == 1); self::$bPageMode = ($iCurrent == 1);

View File

@@ -21,8 +21,6 @@ class Session
/** @var int|null */ /** @var int|null */
public static $iSessionId = null; public static $iSessionId = null;
/** @var bool */ /** @var bool */
protected static $bIsInitialized = false;
/** @var bool */
public static $bAllowCLI = false; public static $bAllowCLI = false;
public static function Start() public static function Start()
@@ -31,19 +29,15 @@ class Session
return; return;
} }
if (session_status() === PHP_SESSION_ACTIVE) { if (session_status() === PHP_SESSION_ACTIVE || headers_sent()) {
// Session already started // Session already started
self::$bIsInitialized = true;
self::$iSessionId = session_id(); self::$iSessionId = session_id();
return; return;
} }
if (!headers_sent()) { SessionHandler::session_set_save_handler();
SessionHandler::session_set_save_handler(); session_name('itop-'.md5(APPROOT));
session_name('itop-'.md5(APPROOT));
}
self::$bIsInitialized = true;
if (!is_null(self::$iSessionId)) { if (!is_null(self::$iSessionId)) {
if (session_id(self::$iSessionId) === false) { if (session_id(self::$iSessionId) === false) {
session_regenerate_id(true); session_regenerate_id(true);
@@ -55,7 +49,7 @@ class Session
public static function RegenerateId($bDeleteOldSession = false) public static function RegenerateId($bDeleteOldSession = false)
{ {
if (session_status() === PHP_SESSION_DISABLED) { if (session_status() === PHP_SESSION_DISABLED || headers_sent()) {
return; return;
} }
@@ -192,14 +186,6 @@ class Session
return array_keys($_SESSION); return array_keys($_SESSION);
} }
/**
* @return bool
*/
public static function IsInitialized(): bool
{
return self::$bIsInitialized;
}
/** /**
* @return bool|string * @return bool|string
*/ */