mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
N°4974 - Session rework
This commit is contained in:
@@ -1838,6 +1838,7 @@ class UserRights
|
||||
self::$m_aAdmins = array();
|
||||
self::$m_aPortalUsers = array();
|
||||
}
|
||||
Session::FlushSession();
|
||||
self::_ResetSessionCache();
|
||||
if (self::$m_oAddOn)
|
||||
{
|
||||
@@ -1936,7 +1937,7 @@ class UserRights
|
||||
// The bug has been fixed in PHP 7.2, but in case session_regenerate_id()
|
||||
// fails we just silently ignore the error and keep the same session id...
|
||||
$old_error_handler = set_error_handler(array(__CLASS__, 'VoidErrorHandler'));
|
||||
session_regenerate_id(true);
|
||||
Session::RegenerateId(true);
|
||||
if ($old_error_handler !== null) {
|
||||
set_error_handler($old_error_handler);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
namespace Combodo\iTop\Application\Helper;
|
||||
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Session management
|
||||
* Allow early session close to have multiple ajax calls in parallel
|
||||
@@ -25,14 +27,19 @@ class Session
|
||||
|
||||
public static function Start()
|
||||
{
|
||||
if (utils::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 +47,36 @@ class Session
|
||||
}
|
||||
}
|
||||
|
||||
public static function FlushSession()
|
||||
{
|
||||
if (utils::IsModeCLI()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_null(self::$iSessionId)) {
|
||||
self::$bIsInitialized = false;
|
||||
self::$bSessionStarted = false;
|
||||
self::Start();
|
||||
}
|
||||
}
|
||||
|
||||
public static function RegenerateId($bDeleteOldSession = false)
|
||||
{
|
||||
if (utils::IsModeCLI()) {
|
||||
return;
|
||||
}
|
||||
|
||||
session_regenerate_id($bDeleteOldSession);
|
||||
self::$bSessionStarted = session_start();
|
||||
self::$iSessionId = session_id();
|
||||
}
|
||||
|
||||
public static function WriteClose()
|
||||
{
|
||||
if (utils::IsModeCLI()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self::$bSessionStarted) {
|
||||
session_write_close();
|
||||
self::$bSessionStarted = false;
|
||||
|
||||
Reference in New Issue
Block a user