function masquerade_init in Masquerade 6
Same name and namespace in other branches
- 5 masquerade.module \masquerade_init()
- 7 masquerade.module \masquerade_init()
Implementation of hook_init().
File
- ./
masquerade.module, line 33 - masquerade.module
Code
function masquerade_init() {
global $user;
// Try to load masqing uid from masquerade table.
$uid = db_result(db_query("SELECT uid_from FROM {masquerade} WHERE sid = '%s' AND uid_as = %d", session_id(), $user->uid));
// We are using identical operator (===) instead of equal (==) because if
// $uid === 0 we want to store the session variable. If there's no record in
// masquerade table we clear the session variable.
if ($uid === FALSE) {
if (isset($_SESSION)) {
unset($_SESSION['masquerading']);
}
}
else {
$_SESSION['masquerading'] = $uid;
}
}