Skip to content

Commit

Permalink
Update from review
Browse files Browse the repository at this point in the history
  • Loading branch information
elioermini authored and jignesh-baldha committed Aug 14, 2018
1 parent 5b6e78e commit e688b8a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/internal/Magento/Framework/Session/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,6 +15,11 @@
*/
class SessionManager implements SessionManagerInterface
{
/**
* Session destroyed threshold in seconds
*/
const SESSION_DESTROYED_THRESHOLD = 300;

/**
* Default options when a call destroy()
*
Expand Down Expand Up @@ -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]);
}
}
Expand Down Expand Up @@ -511,32 +513,29 @@ 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']);
unset($_SESSION['new_session_id']);
} else {
session_start();
}
// @codingStandardsIgnoreEnd
$this->storage->init(isset($_SESSION) ? $_SESSION : []);

if ($this->sessionConfig->getUseCookies()) {
Expand Down

0 comments on commit e688b8a

Please sign in to comment.