コード例 #1
0
 /**
  * Login to the system
  * Login to the system with specified user ID
  *
  * NOTE: This will reset session variables and possibly session ID too
  *
  * @param integer $userid Login with this user ID
  * @param boolean $recordLastLogin Whether or not to record last login
  * @param boolean $clearStack Whether or not to clear login stack
  *
  * @return boolean Returns TRUE if successful, FALSE othwerwise
  */
 public static final function userLogin($userid, $recordLastLogin = true, $clearStack = false)
 {
     $userid = intval($userid);
     if (empty($userid)) {
         return false;
     }
     $user = GetUser($userid);
     if (!$user) {
         return false;
     }
     // Do we want to record this?
     if ($recordLastLogin) {
         $rand_check = uniqid(true);
         $user->settings['LoginCheck'] = $rand_check;
         $user->SaveSettings();
         $user->UpdateLoginTime();
     }
     if ($clearStack) {
         self::$_userStack = array();
     }
     self::$_userStack[] = $user->userid;
     self::$_userCacheObject = $user;
     // ----- Save user information into session
     IEM::sessionReset();
     IEM::sessionSet('__IEM_SYSTEM_CurrentUser_Stack', self::$_userStack);
     // -----
     return true;
 }