Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the Session ID in a Symfony action?

I'm using Symfony 1.4 and Doctrine 1.2. I need to get the session ID inside an action.

I'm using doctrine session storage and that works fine. I'm also using sfDoctrineGuardPlugin and am able to get and set session variables in the user according to recommended practice, using code like this:

$this->getUser()->setAttribute('variable_name', $value);
$value = $this->getUser()->getAttribute('variable_name');

But how do I get the session id of the current user?

like image 839
ybull Avatar asked Oct 22 '25 21:10

ybull


1 Answers

It seems like you can't access the sfStorage from the user object. The sfSessionStorage stores the user data in the session...

So the only way I currently see is calling the 'native' session_id().

If you want to it perfectly you should extends the sfSessionStorage adding a method to retrieve the session id. Then assign this storage to the user, and you would be able to call $this->getUser()->getStorage()->getSessionId();.

like image 189
Grad van Horck Avatar answered Oct 26 '25 02:10

Grad van Horck