Следующее должно позволить вам создать новую Zend_Auth
личность после успешного входа в систему:
$identity = Zend_Auth::getInstance()->getStorage();
$identity->write($userData);
Что касается пользовательских данных, я обычно храню строку базы данных, соответствующую пользователю, с обязательными полями, такими как Имя, фамилия, адрес электронной почты, роль, чтобы назвать несколько. Если вы сохраните Zend_Db_TableRow
в Zend_Auth
, вы сможете получить к нему следующий доступ:
Zend_Auth::getInstance()->getIdentity()->role;
Быстрое напоминание о 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
Более подробно вы можете прочитать в официальной документации: Zend_Auth