_storage) { require_once 'Zend/Auth/Storage/Session.php'; $this->setStorage(new Zend_Auth_Storage_Session()); } return $this->_storage; } public function setStorage(Zend_Auth_Storage_Interface $storage) { $this->_storage = $storage; return $this; } public function authenticate(Zend_Auth_Adapter_Interface $adapter) { $result = $adapter->authenticate(); if ($this->hasIdentity()) { $this->clearIdentity(); } if ($result->isValid()) { $this->getStorage()->write($result->getIdentity()); } return $result; } public function hasIdentity() { return !$this->getStorage()->isEmpty(); } public function getIdentity() { $storage = $this->getStorage(); if ($storage->isEmpty()) { return null; } return $storage->read(); } public function clearIdentity() { $this->getStorage()->clear(); } }