Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UserController.php

function 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 396

Class

UserController
Controller routines for user routes.

Namespace

Drupal\user\Controller

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal