Php Session and Yii Session


I have Yii Session like Yii::app()->user->id,

I Set Php Session $_SESSION[‘id’]=85;

I cant get Result Session in this Yii::app()->user->id,

Why?But I got result Yii::app()->session[‘id’];

Now i want Php Session id in Yii::app()->user->id;How it related?

Don’t use $_SESSION[‘id’];

Instead use Yii functions:

To set session data use:

Yii::app()->user->setState('firstName', 'John');

Yii::app()->user->setState('lastName', 'Doe');

To get session data use:




How to Use Yii Class in Php I Set Session in php file?

What U should use is:

Yii::app()->session->get(‘key’); for yous purpose Yii::app()->session->get(‘id’) for getting session id, Do not use Yii::app()->user-> for this cause it was not meant for habdling session.

also U can set session by using Yii::app()->session->add($key, $value);

please check this ChttpSession

1 Like


I Completed My site I used My Site full Getting User id like this Yii::app()->user,I am Using Social login Using HYbridauth php in that i create that Session in php.I am trying to integrate hybridauth in yii but i cant do because in my site already having Usercontroller its both are confilct in my site…