Extending WebUser

Hello All,

I am bit confused with the below approach . If you guys look at the getUser method , If I call this method from any action it always goes to the NULL condition ( always satisfies $this->_user === null condition) . For example if I call this method from view action and again from update action it var dumps the user twice ( Going to the NULL condition ) . I thought during the session it only satisfies the null condition only first time and only once and for the remaining requests it just picks the value from session and not by querying again database .

I believe this is same as Yii::app()->user->setState()


 class WebUser extends CWebUser{

     private $_user;

       //get the logged user

     function getUser(){

      if( $this->isGuest )

       return;

      if( $this->_user === null ){

       Yii::trace(CVarDumper::dumpAsString($this->_user), 'vardump');

       $this->_user = User::model()->findByPk( $this->id );

      }

      return $this->_user;

     }

   }

Could some one clarify ?

Thanks

Yii FAN

Just noticed one more thing

Yii::app()->user->setState(‘var1’,‘value1’);

Yii::app()->session[‘var2’] = ‘value2’;

If I set these in one action and in the view if I have dependent dropdown boxes and to populate second combo box I am calling ajax call . In the ajax call action method if I print the above two first time they are printing and the second time the values are disappearing .

Just want to point it down … or may be some thing I am doing wrong …?

Regards

Yii fan

sorry it is my bad . In the below code I was returning ‘1’ instead of ‘true’ Not sure why i did this . This killed my two days . But still debugging … as usual if I get any issue on this I will post




             if($this->_identity->errorCode===UserIdentity::ERROR_NONE)

		{


			$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days

			Yii::app()->user->login($this->_identity,$duration);

			return true;

		}