Skip to content

Commit b186567

Browse files
author
Stanislav Idolov
committed
Fixed minor issues
1 parent 5dbce2a commit b186567

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/internal/Magento/Framework/Session/SessionManager.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
*/
1616
class SessionManager implements SessionManagerInterface
1717
{
18-
/**
19-
* Session destroyed threshold in seconds
20-
*/
21-
const SESSION_DESTROYED_THRESHOLD = 300;
22-
2318
/**
2419
* Default options when a call destroy()
2520
*
@@ -197,11 +192,12 @@ public function start()
197192
// potential custom logic for session id (ex. switching between hosts)
198193
$this->setSessionId($sid);
199194
session_start();
200-
if (isset($_SESSION['destroyed'])) {
201-
if ($_SESSION['destroyed'] < time() - self::SESSION_DESTROYED_THRESHOLD) {
202-
$this->destroy(['clear_storage' => true]);
203-
}
195+
if (isset($_SESSION['destroyed'])
196+
&& $_SESSION['destroyed'] < time() - $this->sessionConfig->getCookieLifetime()
197+
) {
198+
$this->destroy(['clear_storage' => true]);
204199
}
200+
205201
$this->validator->validate($this);
206202
$this->renewCookie($sid);
207203

@@ -516,29 +512,34 @@ public function regenerateId()
516512
return $this;
517513
}
518514

519-
// @codingStandardsIgnoreStart
520515
if ($this->isSessionExists()) {
516+
521517
// Regenerate the session
522518
session_regenerate_id();
523519
$newSessionId = session_id();
524520
$_SESSION['new_session_id'] = $newSessionId;
521+
525522
// Set destroy timestamp
526523
$_SESSION['destroyed'] = time();
524+
527525
// Write and close current session;
528526
session_commit();
527+
529528
// Called after destroy()
530529
$oldSession = $_SESSION;
530+
531531
// Start session with new session ID
532532
session_id($newSessionId);
533533
session_start();
534534
$_SESSION = $oldSession;
535+
535536
// New session does not need them
536537
unset($_SESSION['destroyed']);
537538
unset($_SESSION['new_session_id']);
538539
} else {
539540
session_start();
540541
}
541-
// @codingStandardsIgnoreEnd
542+
542543
$this->storage->init(isset($_SESSION) ? $_SESSION : []);
543544

544545
if ($this->sessionConfig->getUseCookies()) {

0 commit comments

Comments
 (0)