1 user.pages.inc user_logout()

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

File

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

Code

function user_logout() {
  global $user;

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

  module_invoke_all('user_logout', $user);

  $entity_info = entity_get_info('user');
  if (isset($entity_info['entity cache']) && $entity_info['entity cache']) {
    cache('entity_user')->delete($user->uid);
  }

  // Destroy the current session, and reset $user to the anonymous user.
  session_destroy();

  backdrop_goto();
}