function UserAuthenticationController::logout

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

Logs out a user.

Attributes

#[Route(path: '/user/logout', name: 'user.logout.http', methods: [ 'POST', ], requirements: [ '_user_is_logged_in' => 'TRUE', '_format' => 'json', '_csrf_token' => 'TRUE', ])]

Return value

\Symfony\Component\HttpFoundation\Response The response object.

File

core/modules/user/src/Controller/UserAuthenticationController.php, line 321

Class

UserAuthenticationController
Provides controllers for login, login status and logout via HTTP requests.

Namespace

Drupal\user\Controller

Code

public function logout() {
  $this->userLogout();
  return new Response(NULL, 204);
}

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