Log in as other user

Without other modules:

$uid = 777;
$form_state = array();
$form_state['uid'] = $uid;
user_login_submit(array(), $form_state);