Use Zend_Session_Namespace
to store the object. It can be as temporary or permanent as you wish to make it.
Zend_Auth already uses this in the background as it's default storage mechanism using the namespace of Zend_Auth
.
class Plugin_Auth extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$session = new Zend_Session_Namespace('user');//instantiate session namespace
if ($auth->hasIdentity())
{
$id = $auth->getIdentity()->id;
$userModel = new Model_User();
$user = $userModel->fetchOne($id);
$session->user = $user;//store the object can be recalled anywhere
}
}
}
Of course Zend_Registry will work as well and as always the choice is yours. You may even find it appropriate to build this functionality into your auth adapter.