function UserController::logout

Same name in other branches
  1. 9 core/modules/user/src/Controller/UserController.php \Drupal\user\Controller\UserController::logout()
  2. 10 core/modules/user/src/Controller/UserController.php \Drupal\user\Controller\UserController::logout()
  3. 11.x core/modules/user/src/Controller/UserController.php \Drupal\user\Controller\UserController::logout()

Logs the current user out.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirection to home page.

1 string reference to 'UserController::logout'
user.routing.yml in core/modules/user/user.routing.yml
core/modules/user/user.routing.yml

File

core/modules/user/src/Controller/UserController.php, line 319

Class

UserController
Controller routines for user routes.

Namespace

Drupal\user\Controller

Code

public function logout() {
    user_logout();
    return $this->redirect('<front>');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.