You are here

function services_session_unload in Services 5

Same name and namespace in other branches
  1. 6.3 services.runtime.inc \services_session_unload()
  2. 6 services.module \services_session_unload()
  3. 6.2 services.module \services_session_unload()
  4. 7 services.module \services_session_unload()

Revert to previously backuped session.

2 calls to services_session_unload()
services_method_call in ./services.module
This is the magic function through which all remote method calls must pass.
services_session_load in ./services.module
Backup current session data and import user session.

File

./services.module, line 638
The module which provides the core code for drupal services

Code

function services_session_unload($backup) {
  global $user;

  // No point in reverting if it's the same user's data
  if ($user->sid == $backup->sid) {
    return;
  }

  // Some client/servers, like XMLRPC, do not handle cookies, so imitate it to make sess_read() function try to look for user,
  // instead of just loading anonymous user :).
  if (!isset($_COOKIE[session_name()])) {
    $_COOKIE[session_name()] = $sessid;
  }

  // Save current session data
  sess_write($user->sid, session_encode());

  // Empty current session data
  foreach ($_SESSION as $key => $value) {
    unset($_SESSION[$key]);
  }

  // Revert to previous user and session data
  $user = $backup;
  session_id($backup->sessid);
  session_decode($user->session);
}