protected function PrivateTempStore::startSession in Drupal 9
Same name and namespace in other branches
- 8 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.
2 calls to PrivateTempStore::startSession()
- PrivateTempStore::getOwner in core/
lib/ Drupal/ Core/ TempStore/ PrivateTempStore.php - Gets the current owner based on the current user or the session ID.
- PrivateTempStore::set in core/
lib/ Drupal/ Core/ TempStore/ PrivateTempStore.php - Stores a particular key/value pair in this PrivateTempStore.
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();
}
}