Our support staff needed a way to quickly and easily log in as clients without needing to:
1) log out themselves
2) use a secondbrowser
3) obtain the client's credentials
...so we added a snippet of jQuery to the footer of the project that presented a "Log in as..." or "Resume as..." button on particular pages (in each row of the users' List/Grid page, and on the View page).
We then added a snippet of PHP to the header:
// switch from admin/staff to a regular profile
if (CurrentUserLevel() != 1 && isset($GET['SetProfile'])) {
$SESSION['ROOT_PROFILE'] = array(
'SysAdmin' => $SESSION['YourProject_SysAdmin'],
'Level' => $SESSION['YourProject_status_UserLevel'],
'ID' => $SESSION['YourProject_status_UserName']
);
$SESSION['YourProject_SysAdmin'] = 0;
$SESSION['YourProject_status_UserLevel'] = 0;
unset($SESSION['YourProject_status_UserLevelValue']);
$SESSION['YourProject_status_UserName'] = (int) $GET['SetProfile'];
$SESSION['YourProject_status_UserProfile_UserName'] = (int) $GET['SetProfile'];
header("Location: your_default_page.php");
exit;
}
// resume to admin/staff from a regular profile
else if (CurrentUserLevel() == 0 && isset($GET['ResumeRootProfile']) && isset($SESSION['ROOT_PROFILE'])) {
$SESSION['YourProject_SysAdmin'] = $SESSION['ROOT_PROFILE']['SysAdmin'];
$SESSION['YourProject_status_UserLevel'] = $SESSION['ROOT_PROFILE']['Level'];
$SESSION['YourProject_status_UserName'] = $SESSION['ROOT_PROFILE']['ID'];
$SESSION['YourProject_status_UserProfile_UserName'] = $SESSION['ROOT_PROFILE']['ID'];
unset($SESSION['ROOT_PROFILE']);
header("Location: your_default_page.php");
exit;
}