From e688b8a5ed1539f48056d850fb2c7c0529ec43d3 Mon Sep 17 00:00:00 2001 From: Elio Ermini Date: Fri, 11 May 2018 00:43:56 +0100 Subject: [PATCH] Update from review --- .../Framework/Session/SessionManager.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/internal/Magento/Framework/Session/SessionManager.php b/lib/internal/Magento/Framework/Session/SessionManager.php index 52b2a480400fd..ca8d3d92d7609 100644 --- a/lib/internal/Magento/Framework/Session/SessionManager.php +++ b/lib/internal/Magento/Framework/Session/SessionManager.php @@ -5,9 +5,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - -// @codingStandardsIgnoreFile - namespace Magento\Framework\Session; use Magento\Framework\Session\Config\ConfigInterface; @@ -18,6 +15,11 @@ */ class SessionManager implements SessionManagerInterface { + /** + * Session destroyed threshold in seconds + */ + const SESSION_DESTROYED_THRESHOLD = 300; + /** * Default options when a call destroy() * @@ -193,7 +195,7 @@ public function start() $this->setSessionId($sid); session_start(); if (isset($_SESSION['destroyed'])) { - if ($_SESSION['destroyed'] < time() - 300) { + if ($_SESSION['destroyed'] < time() - self::SESSION_DESTROYED_THRESHOLD) { $this->destroy(['clear_storage' => true]); } } @@ -511,25 +513,21 @@ public function regenerateId() return $this; } + // @codingStandardsIgnoreStart if ($this->isSessionExists()) { // Regenerate the session session_regenerate_id(); $newSessionId = session_id(); - $_SESSION['new_session_id'] = $newSessionId; - // Set destroy timestamp $_SESSION['destroyed'] = time(); - // Write and close current session; session_commit(); // Called after destroy() $oldSession = $_SESSION; // Start session with new session ID session_id($newSessionId); - ini_set('session.use_strict_mode', 0); session_start(); - ini_set('session.use_strict_mode', 1); $_SESSION = $oldSession; // New session does not need them unset($_SESSION['destroyed']); @@ -537,6 +535,7 @@ public function regenerateId() } else { session_start(); } + // @codingStandardsIgnoreEnd $this->storage->init(isset($_SESSION) ? $_SESSION : []); if ($this->sessionConfig->getUseCookies()) {