$ui = UserInfo::getByUserName($username); $u = $ui->getUserObject(); $userID = $u->getUserID(); User::loginByUserID($userID);