You are here

function _user_resource_logout in Services 6.3

Same name and namespace in other branches
  1. 7.3 resources/user_resource.inc \_user_resource_logout()

Logout the current user.

1 string reference to '_user_resource_logout'
_user_resource_definition in resources/user_resource.inc
@file This file will define the resources for dealing with the user object

File

resources/user_resource.inc, line 407
This file will define the resources for dealing with the user object

Code

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

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

  // Only variables can be passed by reference workaround
  user_module_invoke('logout', $null, $user);

  // Destroy the current session.
  session_destroy();

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