8.3.x user.module user_logout()
8.0.x user.module user_logout()
8.1.x user.module user_logout()
8.2.x user.module user_logout()
8.4.x user.module user_logout()
4.6.x user.module user_logout()
4.7.x user.module user_logout()
5.x user.module user_logout()
6.x user.pages.inc user_logout()
7.x user.pages.inc user_logout()

Menu callback; logs the current user out, and redirects to the home page.

1 call to user_logout()
_menu_site_is_offline in includes/menu.inc
Checks whether the site is off-line for maintenance.
1 string reference to 'user_logout'
user_menu in modules/user/user.module
Implementation of hook_menu().

File

modules/user/user.pages.inc, line 145
User page callback file for the user module.

Code

function user_logout() {
  global $user;

  watchdog('user', 'Session closed for %name.', array('%name' => $user->name));

  // Destroy the current session:
  session_destroy();
  // Only variables can be passed by reference workaround.
  $null = NULL;
  user_module_invoke('logout', $null, $user);

  // Load the anonymous user
  $user = drupal_anonymous_user();

  drupal_goto();
}