Bitrix Site Manager

CUser::Authorize

bool
CUser::Authorize(
 int user_id
)

The method Authorize implements the user authorization procedure. Initialises both session and CUser variables. Returns true on successful authorization, or false otherwise.

Parameters

ParameterDescription
user_id User ID.

See Also

Example



<?
// 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
?>