function SessionManager::getSessionDataMask
Same name in other branches
- 9 core/lib/Drupal/Core/Session/SessionManager.php \Drupal\Core\Session\SessionManager::getSessionDataMask()
- 8.9.x core/lib/Drupal/Core/Session/SessionManager.php \Drupal\Core\Session\SessionManager::getSessionDataMask()
- 11.x core/lib/Drupal/Core/Session/SessionManager.php \Drupal\Core\Session\SessionManager::getSessionDataMask()
Returns a map specifying which session key is containing user data.
Return value
array An array where keys correspond to the session keys and the values are booleans specifying whether the corresponding session key contains any user data.
1 call to SessionManager::getSessionDataMask()
- SessionManager::isSessionObsolete in core/
lib/ Drupal/ Core/ Session/ SessionManager.php - Determines whether the session contains user data.
File
-
core/
lib/ Drupal/ Core/ Session/ SessionManager.php, line 311
Class
- SessionManager
- Manages user sessions.
Namespace
Drupal\Core\SessionCode
protected function getSessionDataMask() {
if (empty($_SESSION)) {
return [];
}
// Start out with a completely filled mask.
$mask = array_fill_keys(array_keys($_SESSION), TRUE);
// Ignore the metadata bag, it does not contain any user data.
$mask[$this->metadataBag
->getStorageKey()] = FALSE;
// Ignore attribute bags when they do not contain any data.
foreach ($this->bags as $bag) {
$key = $bag->getStorageKey();
$mask[$key] = !empty($_SESSION[$key]);
}
return array_intersect_key($mask, $_SESSION);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.