我正在Yi建立一个网站,我被困在用户认证步骤上。 不管怎么做,我都无法认证用户,也无法在届会期间储存一些价值。
我的用户特性如下:
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate(){
if(($userRecord = Admin::model()->findByAttributes(array( username =>$this->username)))===null){
return $this->errorCode=self::ERROR_USERNAME_INVALID;
}
if($userRecord->password!=hash( sha256 , $this->password)){
return $this->errorCode=self::ERROR_PASSWORD_INVALID;
}
$this->_id=$userRecord->id;
$this->setState( title , $userRecord->username);
Yii::app()->session[ clientId ] = $userRecord->clientId;
Yii::app()->session[ id ] = $userRecord->id;
Yii::app()->session[ loggedin ] = true;
return $this->errorCode=self::ERROR_NONE;
}
public function getId(){
return $this->_id;
}
}
My Yii:app()->user->isGuest
总回报真实,Yii:app()->user->id
That is why I tried using Yii::app()->session[ loggedin ]
to do authentication. But even that is not working. When I access session array like this Yii::app()->session
I get the error Property "CWebUser.session" is not defined.
.
这正真正令人沮丧。 我是新到的。 请提供帮助。