function devel_switch_user
Switches to a different user.
We don't call session_save_session() because we really want to change users. Usually unsafe!
Parameters
string $name: The username to switch to, or NULL to log out.
1 string reference to 'devel_switch_user'
- devel_menu in ./
devel.module - Implements hook_menu().
File
-
./
devel.module, line 1475
Code
function devel_switch_user($name = NULL) {
global $user;
if ($user->uid) {
module_invoke_all('user_logout', $user);
}
if (isset($name) && ($account = user_load_by_name($name))) {
$old_uid = $user->uid;
$user = $account;
$user->timestamp = time() - 9999;
if (!$old_uid) {
// Switch from anonymous to authorized.
drupal_session_regenerate();
}
$edit = array();
user_module_invoke('login', $edit, $user);
}
elseif ($user->uid) {
session_destroy();
}
drupal_goto();
}