mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
Merge remote-tracking branch 'origin/support/3.0' into develop
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
namespace Combodo\iTop\Application\Helper;
|
||||
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Session management
|
||||
* Allow early session close to have multiple ajax calls in parallel
|
||||
@@ -22,17 +24,24 @@ class Session
|
||||
protected static $bIsInitialized = false;
|
||||
/** @var bool */
|
||||
protected static $bSessionStarted = false;
|
||||
/** @var bool */
|
||||
public static $bAllowCLI = false;
|
||||
|
||||
public static function Start()
|
||||
{
|
||||
if (self::IsModeCLI()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self::$bIsInitialized) {
|
||||
session_name('itop-'.md5(APPROOT));
|
||||
}
|
||||
|
||||
self::$bIsInitialized = true;
|
||||
if (!self::$bSessionStarted) {
|
||||
if (!is_null(self::$iSessionId)) {
|
||||
if (session_id(self::$iSessionId) === false) {
|
||||
session_regenerate_id();
|
||||
session_regenerate_id(true);
|
||||
}
|
||||
}
|
||||
self::$bSessionStarted = session_start();
|
||||
@@ -40,8 +49,26 @@ class Session
|
||||
}
|
||||
}
|
||||
|
||||
public static function RegenerateId($bDeleteOldSession = false)
|
||||
{
|
||||
if (self::IsModeCLI()) {
|
||||
return;
|
||||
}
|
||||
|
||||
session_regenerate_id($bDeleteOldSession);
|
||||
if (self::$bSessionStarted) {
|
||||
self::WriteClose();
|
||||
}
|
||||
self::$bSessionStarted = session_start();
|
||||
self::$iSessionId = session_id();
|
||||
}
|
||||
|
||||
public static function WriteClose()
|
||||
{
|
||||
if (self::IsModeCLI()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self::$bSessionStarted) {
|
||||
session_write_close();
|
||||
self::$bSessionStarted = false;
|
||||
@@ -177,4 +204,14 @@ class Session
|
||||
{
|
||||
return print_r($_SESSION, true);
|
||||
}
|
||||
|
||||
private static function IsModeCLI(): bool
|
||||
{
|
||||
if (self::$bAllowCLI) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return utils::IsModeCLI();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user