A
A
Artem Gribkov2014-06-09 10:05:51
Yii
Artem Gribkov, 2014-06-09 10:05:51

Get user_id from cookie?

When a user logs in, the session with his data: id, name, states, is written in cookies in the following form:

[6c85ab700016235bf55b3c6eb945a6e3] => a54d3314c3fe7c14c09a1bc001a6830bc72fe488a:4:{i:0;s:1:"8";i:1;s:13:"testuser";i:2;i:31556926;i:3;a:0:{}}

So is it possible to get the id parameter using standard yii tools?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2014-06-09
@0neS

$session = Yii::app()->session;
echo $session['id'];
echo $session['name'];
echo $session['states'];

Or:
$user = Yii::app()->user;
echp $user->getState('id');
echp $user->getState('name');
echp $user->getState('states');

Their differences .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question