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?
It seems like you can’t access the
sfStoragefrom the user object. ThesfSessionStoragestores 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
sfSessionStorageadding 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();.