protected function PrivateTempStore::startSession in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/TempStore/PrivateTempStore.php \Drupal\Core\TempStore\PrivateTempStore::startSession()
- 9 core/lib/Drupal/Core/TempStore/PrivateTempStore.php \Drupal\Core\TempStore\PrivateTempStore::startSession()
Start session because it is required for a private temp store.
Ensures that an anonymous user has a session created for them, as otherwise subsequent page loads will not be able to retrieve their tempstore data.
@todo when https://www.drupal.org/node/2865991 is resolved, use force start session API.
File
- core/
lib/ Drupal/ Core/ TempStore/ PrivateTempStore.php, line 245
Class
- PrivateTempStore
- Stores and retrieves temporary data for a given owner.
Namespace
Drupal\Core\TempStoreCode
protected function startSession() {
$has_session = $this->requestStack
->getCurrentRequest()
->hasSession();
if (!$has_session) {
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $session */
$session = \Drupal::service('session');
$this->requestStack
->getCurrentRequest()
->setSession($session);
$session
->start();
}
}