How to fetch values of sessions?


I’ve set the session using Yii::app()->session and then when i tried to pass the values of these session variables it shows the following error

Object of class CWebUser could not be converted to string 

earlier in my code i set the session using


and then i’m trying this

$this->friends = $mCrew->getMembers(Yii::app()->session['fbuid'],$this->sub_roleid);

By the way what’s the difference between setting a session using CHTTPSession and Yii::app()->session

  $session=new CHttpSession;


  $value1=$session['name1'];  // get session variable 'name1'

  $value2=$session['name2'];  // get session variable 'name2'

  foreach($session as $name=>$value) // traverse all session variables

  $session['name3']=$value3;  // set session variable 'name3'

what will be the equivalent code for the above using yii::app()->session?

Use Yii::app()->user->getState() and setState(). Yii::app()->session is the component managing the session, not the session itself ;)

What is meant by yii::app()->user , i dont need to update the default user session of yii… If i need to create a new session variable and put some values for that and then if i need to retrieve the session value , what should i do?

Yii::app()->user is the current user. setState() and getState() will set/get a desired session value.

How can i create my own session instead of using the user? consider if i need multi dimensional sessions…?!