Documentation

Authorize

bool
CUser::Authorize(
 int user_id,
 bool Save = false,
 bool Update = true
)

The method directly implements the user authorization procedure. It initializes both session and CUser variables. Returns true on successful authorization, or false otherwise. Non-static method.

Parameters

ParameterDescription Available from version
user_id User ID.
bSaveFlag that specifies the requirement to remember user authorization data. If true, a random hash will be generated and a cookie with its value created. This hash will be saved in the data base for subsequent authorization via the CUser::LoginByHash method.
Update Optional parameter; true by default.

See Also

Examples of use

<?
// 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
$arrGroups = array_unique(array_merge($arrGroups_old, $arrGroups_new)); // join arrays and remove duplicates
$USER->Update($USER->GetID(), array("GROUP_ID" => $arrGroups)); // update user profile in the database
$USER->Authorize($USER->GetID()); // authorize
?>


© «Bitrix24», 2001-2024