0

我想在成功登录后创建随机会话并在注销后将其销毁。怎么办?我使用了 $this->user->setState 我添加了这段代码

class UserIdentity extends CUserIdentity {
    protected $_id;
    public function authenticate(){
        $user = User::model()->find('LOWER(username)=?', array(strtolower($this->username)));
        if(($user===null) || ($this->password!==$user->password)) {
            $this->errorCode = self::ERROR_USERNAME_INVALID;
        } else {
            $this->_id = $user->id;
            $this->username = $user->username;
            $this->user->setState('random',Yii::app()->user->random);
            $this->errorCode = self::ERROR_NONE;
        }
       return !$this->errorCode;
    }

    public function getId(){
        return $this->_id;
    }
}
4

1 回答 1

0

使用 $this->setState 而不是 $this->user->setState

于 2015-01-24T19:44:27.447 回答