function LogoutFinalizer::finalizeLogout
Same name and namespace in other branches
- 11.x core/modules/user/src/LogoutFinalizer.php \Drupal\user\LogoutFinalizer::finalizeLogout()
Logs the current user out.
File
-
core/
modules/ user/ src/ LogoutFinalizer.php, line 30
Class
- LogoutFinalizer
- Finalize user logout.
Namespace
Drupal\userCode
public function finalizeLogout() : void {
$this->logger
->info('Session closed for %name.', [
'%name' => $this->accountProxy
->getAccountName(),
]);
$this->moduleHandler
->invokeAll('user_logout', [
$this->accountProxy,
]);
// Destroy the current session, and reset $user to the anonymous user.
// Note: In Symfony the session is intended to be destroyed with
// Session::invalidate(). Regrettably this method is currently broken and
// may lead to the creation of spurious session records in the database.
// @see https://github.com/symfony/symfony/issues/12375
$this->sessionManager
->destroy();
$this->accountProxy
->setAccount(new AnonymousUserSession());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.