function services_session_unload in Services 6.2
Same name and namespace in other branches
- 5 services.module \services_session_unload()
- 6.3 services.runtime.inc \services_session_unload()
- 6 services.module \services_session_unload()
- 7 services.module \services_session_unload()
Revert to previously backed up session.
Parameters
$backup: Session information previously backed up in services_session_load().
1 call to services_session_unload()
- services_session_load in ./
services.module - Backup current session data and import user session.
File
- ./
services.module, line 885 - Provides a generic but powerful API for exposing web 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()] = $backup->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_id($backup->sessid);
session_decode($user->session);
session_save_session(TRUE);
}