The following should allow you to create a new Zend_Auth
identity upon successful login :
$identity = Zend_Auth::getInstance()->getStorage();
$identity->write($userData);
As for the user data, I usually store the database row corresponding to the user with the required fields like Name, surname, email, role, to name a few. If you store a Zend_Db_TableRow
in the Zend_Auth
you will be able to access it like this :
Zend_Auth::getInstance()->getIdentity()->role;
Quick reminder on Zend_Auth
:
$auth = Zend_Auth::getInstance(); // get the `Zend_Auth` instance (build on the singleton pattern)
$auth->hasIdentity(); // return true if an indentity exists and false if it doesn't
$auth->getIdentity(); // allow you to get the identity content (array, Zend_Db_TableRow and such)
$auth->write($data): // allow to create a new identity
$auth->clearIdentity(); // destroy any content stored in the identity. Zend_Session::destroy() can also be used since identity is stored in a session variable
For more you can read the official documentation : Zend_Auth