N°3985 - Performance checks on the back end - Fix Session helper

This commit is contained in:
Eric
2021-08-26 15:33:07 +02:00
parent 5ce9b6ca99
commit 81d9ea389d
2 changed files with 12 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginUIExtension
*/
protected function OnReadCredentials(&$iErrorCode)
{
if (Session::Get('login_mode') == 'form') {
if (!Session::IsSet('login_mode') || Session::Get('login_mode') == 'form') {
$sAuthUser = utils::ReadPostedParam('auth_user', '', 'raw_data');
$sAuthPwd = utils::ReadPostedParam('auth_pwd', null, 'raw_data');
if ($this->bForceFormOnError || empty($sAuthUser) || empty($sAuthPwd))
@@ -51,9 +51,10 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginUIExtension
$this->bForceFormOnError = false;
exit;
}
Session::Start();
Session::Set('login_temp_auth_user', $sAuthUser);
Session::Set('login_mode', 'form');
Session::WriteClose();
}
return LoginWebPage::LOGIN_FSM_CONTINUE;
}

View File

@@ -55,7 +55,8 @@ class Session
*/
public static function Set($key, $value)
{
$sSessionVar = &$_SESSION;
$aSession = $_SESSION;
$sSessionVar = &$aSession;
if (is_array($key)) {
foreach ($key as $sKey) {
$sSessionVar = &$sSessionVar[$sKey];
@@ -63,12 +64,13 @@ class Session
} else {
$sSessionVar = &$sSessionVar[$key];
}
$sSessionVar = $value;
if (!self::$bSessionStarted) {
self::Start();
$sSessionVar = $value;
$_SESSION = $aSession;
self::WriteClose();
} else {
$sSessionVar = $value;
$_SESSION = $aSession;
}
}
@@ -111,7 +113,8 @@ class Session
*/
public static function Get($key, $default = null)
{
$sSessionVar = &$_SESSION;
$aSession = $_SESSION;
$sSessionVar = &$aSession;
if (is_array($key)) {
foreach ($key as $SKey) {
$sSessionVar = &$sSessionVar[$SKey];
@@ -134,7 +137,8 @@ class Session
*/
public static function IsSet($key): bool
{
$sSessionVar = &$_SESSION;
$aSession = $_SESSION;
$sSessionVar = &$aSession;
if (is_array($key)) {
foreach ($key as $SKey) {
$sSessionVar = &$sSessionVar[$SKey];