Using the default Zend_Auth session storage (PHP Sessions), it creates a session ID and puts it in a cookie. If I want to get at the authenticated user's username (identity), the Zend_Auth::getInstance()->getIdentity()
method gets that. However, I want to get at the user's session ID. I can get at it just by looking at $_COOKIE
, or using session_id()
but that seems hackish, and if I ever moved away from PHP Session storage might it break? So what's the best way to get the current session ID of the Zend_Auth session?
I don't think you're going to find a nice way to do this. If such a method existed it would be defined in Zend_Auth_Storage_Interface
, but non-session types of storage don't necessarily have a session ID equivalent so the auth storage classes don't have any abstraction for this. The closest you'll get is probably:
Zend_Session::getId()
but this just calls PHP's session_id()
, since Zend_Session
is dependent on the in-built PHP session functionality.