comparison core/lib/Drupal/Core/Session/SessionManager.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
216 throw new \InvalidArgumentException('The optional parameters $destroy and $lifetime of SessionManager::regenerate() are not supported currently'); 216 throw new \InvalidArgumentException('The optional parameters $destroy and $lifetime of SessionManager::regenerate() are not supported currently');
217 } 217 }
218 218
219 if ($this->isStarted()) { 219 if ($this->isStarted()) {
220 $old_session_id = $this->getId(); 220 $old_session_id = $this->getId();
221 // Save and close the old session. Call the parent method to avoid issue
222 // with session destruction due to the session being considered obsolete.
223 parent::save();
224 // Ensure the session is reloaded correctly.
225 $this->startedLazy = TRUE;
221 } 226 }
222 session_id(Crypt::randomBytesBase64()); 227 session_id(Crypt::randomBytesBase64());
223 228
224 $this->getMetadataBag()->clearCsrfTokenSeed(); 229 $this->getMetadataBag()->clearCsrfTokenSeed();
225 230
228 $expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0; 233 $expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
229 setcookie($this->getName(), $this->getId(), $expire, $params['path'], $params['domain'], $params['secure'], $params['httponly']); 234 setcookie($this->getName(), $this->getId(), $expire, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
230 $this->migrateStoredSession($old_session_id); 235 $this->migrateStoredSession($old_session_id);
231 } 236 }
232 237
233 if (!$this->isStarted()) { 238 $this->startNow();
234 // Start the session when it doesn't exist yet.
235 $this->startNow();
236 }
237 } 239 }
238 240
239 /** 241 /**
240 * {@inheritdoc} 242 * {@inheritdoc}
241 */ 243 */