You are here

function services_session_unload in Services 6

Same name and namespace in other branches
  1. 5 services.module \services_session_unload()
  2. 6.3 services.runtime.inc \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 569
@author Services Dev Team

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
  $_SESSION = array();

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