protected function SharedTempStore::ensureAnonymousSession in Drupal 9
Stores the owner in the session if the user is anonymous.
This method should be called when a value is set.
2 calls to SharedTempStore::ensureAnonymousSession()
- SharedTempStore::set in core/
lib/ Drupal/ Core/ TempStore/ SharedTempStore.php - Stores a particular key/value pair in this SharedTempStore.
- SharedTempStore::setIfNotExists in core/
lib/ Drupal/ Core/ TempStore/ SharedTempStore.php - Stores a particular key/value pair only if the key doesn't already exist.
File
- core/
lib/ Drupal/ Core/ TempStore/ SharedTempStore.php, line 310
Class
- SharedTempStore
- Stores and retrieves temporary data for a given owner.
Namespace
Drupal\Core\TempStoreCode
protected function ensureAnonymousSession() {
// If this is being run from the CLI then the request will not have a
// session.
if ($this->currentUser
->isAnonymous() && $this->requestStack
->getCurrentRequest()
->hasSession()) {
$this->requestStack
->getCurrentRequest()
->getSession()
->set('core.tempstore.shared.owner', $this->owner);
}
}