|
15 | 15 | */
|
16 | 16 | class SessionManager implements SessionManagerInterface
|
17 | 17 | {
|
18 |
| - /** |
19 |
| - * Session destroyed threshold in seconds |
20 |
| - */ |
21 |
| - const SESSION_DESTROYED_THRESHOLD = 300; |
22 |
| - |
23 | 18 | /**
|
24 | 19 | * Default options when a call destroy()
|
25 | 20 | *
|
@@ -194,11 +189,12 @@ public function start()
|
194 | 189 | // potential custom logic for session id (ex. switching between hosts)
|
195 | 190 | $this->setSessionId($sid);
|
196 | 191 | 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]); |
201 | 196 | }
|
| 197 | + |
202 | 198 | $this->validator->validate($this);
|
203 | 199 | $this->renewCookie($sid);
|
204 | 200 |
|
@@ -513,29 +509,34 @@ public function regenerateId()
|
513 | 509 | return $this;
|
514 | 510 | }
|
515 | 511 |
|
516 |
| - // @codingStandardsIgnoreStart |
517 | 512 | if ($this->isSessionExists()) {
|
| 513 | + |
518 | 514 | // Regenerate the session
|
519 | 515 | session_regenerate_id();
|
520 | 516 | $newSessionId = session_id();
|
521 | 517 | $_SESSION['new_session_id'] = $newSessionId;
|
| 518 | + |
522 | 519 | // Set destroy timestamp
|
523 | 520 | $_SESSION['destroyed'] = time();
|
| 521 | + |
524 | 522 | // Write and close current session;
|
525 | 523 | session_commit();
|
| 524 | + |
526 | 525 | // Called after destroy()
|
527 | 526 | $oldSession = $_SESSION;
|
| 527 | + |
528 | 528 | // Start session with new session ID
|
529 | 529 | session_id($newSessionId);
|
530 | 530 | session_start();
|
531 | 531 | $_SESSION = $oldSession;
|
| 532 | + |
532 | 533 | // New session does not need them
|
533 | 534 | unset($_SESSION['destroyed']);
|
534 | 535 | unset($_SESSION['new_session_id']);
|
535 | 536 | } else {
|
536 | 537 | session_start();
|
537 | 538 | }
|
538 |
| - // @codingStandardsIgnoreEnd |
| 539 | + |
539 | 540 | $this->storage->init(isset($_SESSION) ? $_SESSION : []);
|
540 | 541 |
|
541 | 542 | if ($this->sessionConfig->getUseCookies()) {
|
|
0 commit comments