Skip to content

Commit f53cfd7

Browse files
Stanislav Idolovjignesh-baldha
authored andcommitted
Fixed minor issues
1 parent e688b8a commit f53cfd7

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
*
@@ -194,11 +189,12 @@ public function start()
194189
// potential custom logic for session id (ex. switching between hosts)
195190
$this->setSessionId($sid);
196191
session_start();
197-
if (isset($_SESSION['destroyed'])) {
198-
if ($_SESSION['destroyed'] < time() - self::SESSION_DESTROYED_THRESHOLD) {
199-
$this->destroy(['clear_storage' => true]);
200-
}
192+
if (isset($_SESSION['destroyed'])
193+
&& $_SESSION['destroyed'] < time() - $this->sessionConfig->getCookieLifetime()
194+
) {
195+
$this->destroy(['clear_storage' => true]);
201196
}
197+
202198
$this->validator->validate($this);
203199
$this->renewCookie($sid);
204200

@@ -513,29 +509,34 @@ public function regenerateId()
513509
return $this;
514510
}
515511

516-
// @codingStandardsIgnoreStart
517512
if ($this->isSessionExists()) {
513+
518514
// Regenerate the session
519515
session_regenerate_id();
520516
$newSessionId = session_id();
521517
$_SESSION['new_session_id'] = $newSessionId;
518+
522519
// Set destroy timestamp
523520
$_SESSION['destroyed'] = time();
521+
524522
// Write and close current session;
525523
session_commit();
524+
526525
// Called after destroy()
527526
$oldSession = $_SESSION;
527+
528528
// Start session with new session ID
529529
session_id($newSessionId);
530530
session_start();
531531
$_SESSION = $oldSession;
532+
532533
// New session does not need them
533534
unset($_SESSION['destroyed']);
534535
unset($_SESSION['new_session_id']);
535536
} else {
536537
session_start();
537538
}
538-
// @codingStandardsIgnoreEnd
539+
539540
$this->storage->init(isset($_SESSION) ? $_SESSION : []);
540541

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

0 commit comments

Comments
 (0)