if ($this->isStarted()) {
$old_session_id = $this->getId();
+ // Save and close the old session. Call the parent method to avoid issue
+ // with session destruction due to the session being considered obsolete.
+ parent::save();
+ // Ensure the session is reloaded correctly.
+ $this->startedLazy = TRUE;
}
session_id(Crypt::randomBytesBase64());
$this->migrateStoredSession($old_session_id);
}
- if (!$this->isStarted()) {
- // Start the session when it doesn't exist yet.
- $this->startNow();
- }
+ $this->startNow();
}
/**