Please Help!!!! Understanding Sessions

Hi there,

I am having a tough time understanding how to use sessions. I hope you can shed some light.

Here is my workflow:

  • I first create a new identity: $[size="2"]identity=new UserIdentity($username,$password); [/size]
  • [size="2"]Then authenticate: $identity->authenticate(); [/size]
  • [size="2"]Then do this: [/size]

switch($identity->errorCode){[/size]

   		case UserIdentity::ERROR_NONE:

//if we get ERROR_NONE, that means either user was create or authentication was successful.

Yii::app()->user->login($identity);

Yii::app()->session->add('loginState',"loggedIn");




break;

}



[size="2"]However — if I use Yii::app()->user->getIsGuest() - it is not set to true[/size]

[size="2"]also, I can not access Yii::app()->user->loginState ever - [/size]

[size="2"]what am I doing wrong?[/size]

[size="2"]I need to know how to make sessions persist between pages, please help![/size]

if getIsGuest() is not true that means that the user is logged in

[size="2"]Yii::app()->user->loginState - this does not exist[/size]

To save a value to the user session use setState() - http://www.yiiframework.com/doc/api/CWebUser#setState-detail