You are here

function user_service_logout in Services 5

Same name and namespace in other branches
  1. 6 services/user_service/user_service.inc \user_service_logout()
  2. 6.2 services/user_service/user_service.inc \user_service_logout()
  3. 7 services/user_service/user_service.inc \user_service_logout()

Logout user

1 string reference to 'user_service_logout'
user_service_service in services/user_service/user_service.module
Implementation of hook_service().

File

services/user_service/user_service.module, line 85
The module which exposes services related to user activities

Code

function user_service_logout() {
  global $user;
  if (!$user->uid) {

    // user is not logged in
    return services_error(t('User is not logged in.'));
  }
  watchdog('user', t('Session closed for %name.', array(
    '%name' => theme('placeholder', $user->name),
  )));

  // Destroy the current session:
  session_destroy();
  module_invoke_all('user', 'logout', NULL, $user);

  // Load the anonymous user
  $user = drupal_anonymous_user();
  return TRUE;
}