The method Authorize implements the user authorization procedure. Initialises both session and CUser variables. Returns true on successful authorization, or false otherwise.
<?
// add a user to a group
// and re-authorize
global $USER; $arrGroups_new = array(3,4); // groups to add to
$arrGroups_old = $USER->GetUserGroupArray(); // obtain current groups
// join arrays and remove duplicates
$arrGroups = array_unique(array_merge($arrGroups_old,
$arrGroups_new));
// update user profile in the database
$USER->Update($USER->GetID(), array("GROUP_ID" => $arrGroups));
$USER->Authorize($USER->GetID()); // authorize
?>