public function KeycloakService::setSessionInfo in Keycloak OpenID Connect 8
Store the Keycloak session information to the user session.
Parameters
array $info: Associative array with session information. The information that will be stored is limited to the allowed keys returned by self::getSessionInfoDefaultKeys().
Return value
bool TRUE, if the information was set, FALSE otherwise.
Overrides KeycloakServiceInterface::setSessionInfo
File
- src/
Service/ KeycloakService.php, line 187
Class
- KeycloakService
- Keycloak service.
Namespace
Drupal\keycloak\ServiceCode
public function setSessionInfo(array $info) {
// Whether the user is not authenticated or the Keycloak client disabled.
if (!$this->currentUser
->isAuthenticated() || !$this
->isEnabled()) {
return FALSE;
}
$default_keys = $this
->getSessionInfoDefaultKeys();
$old_values = $this
->getSessionInfo();
$new_values = array_merge($old_values, $info);
$tempstore = $this->privateTempstore
->get('keycloak');
foreach ($default_keys as $key) {
$tempstore
->set($key, $new_values[$key]);
}
return TRUE;
}