|
5 | 5 | * Copyright © Magento, Inc. All rights reserved.
|
6 | 6 | * See COPYING.txt for license details.
|
7 | 7 | */
|
8 |
| - |
9 |
| -// @codingStandardsIgnoreFile |
10 |
| - |
11 | 8 | namespace Magento\Framework\Session;
|
12 | 9 |
|
13 | 10 | use Magento\Framework\Session\Config\ConfigInterface;
|
|
18 | 15 | */
|
19 | 16 | class SessionManager implements SessionManagerInterface
|
20 | 17 | {
|
| 18 | + /** |
| 19 | + * Session destroyed threshold in seconds |
| 20 | + */ |
| 21 | + const SESSION_DESTROYED_THRESHOLD = 300; |
| 22 | + |
21 | 23 | /**
|
22 | 24 | * Default options when a call destroy()
|
23 | 25 | *
|
@@ -193,7 +195,7 @@ public function start()
|
193 | 195 | $this->setSessionId($sid);
|
194 | 196 | session_start();
|
195 | 197 | if (isset($_SESSION['destroyed'])) {
|
196 |
| - if ($_SESSION['destroyed'] < time() - 300) { |
| 198 | + if ($_SESSION['destroyed'] < time() - self::SESSION_DESTROYED_THRESHOLD) { |
197 | 199 | $this->destroy(['clear_storage' => true]);
|
198 | 200 | }
|
199 | 201 | }
|
@@ -511,32 +513,29 @@ public function regenerateId()
|
511 | 513 | return $this;
|
512 | 514 | }
|
513 | 515 |
|
| 516 | + // @codingStandardsIgnoreStart |
514 | 517 | if ($this->isSessionExists()) {
|
515 | 518 | // Regenerate the session
|
516 | 519 | session_regenerate_id();
|
517 | 520 | $newSessionId = session_id();
|
518 |
| - |
519 | 521 | $_SESSION['new_session_id'] = $newSessionId;
|
520 |
| - |
521 | 522 | // Set destroy timestamp
|
522 | 523 | $_SESSION['destroyed'] = time();
|
523 |
| - |
524 | 524 | // Write and close current session;
|
525 | 525 | session_commit();
|
526 | 526 | // Called after destroy()
|
527 | 527 | $oldSession = $_SESSION;
|
528 | 528 | // Start session with new session ID
|
529 | 529 | session_id($newSessionId);
|
530 |
| - ini_set('session.use_strict_mode', 0); |
531 | 530 | session_start();
|
532 |
| - ini_set('session.use_strict_mode', 1); |
533 | 531 | $_SESSION = $oldSession;
|
534 | 532 | // New session does not need them
|
535 | 533 | unset($_SESSION['destroyed']);
|
536 | 534 | unset($_SESSION['new_session_id']);
|
537 | 535 | } else {
|
538 | 536 | session_start();
|
539 | 537 | }
|
| 538 | + // @codingStandardsIgnoreEnd |
540 | 539 | $this->storage->init(isset($_SESSION) ? $_SESSION : []);
|
541 | 540 |
|
542 | 541 | if ($this->sessionConfig->getUseCookies()) {
|
|
0 commit comments