Authentication state is stored in the registered Auth Storage. By default this is Zend_Session. You can get session by this
$namespace = new Zend_Session_Namespace('Zend_Auth');
then do somthing like this
$namespace->newname = "newvalue";
문제
Good Day to All,
I have the following code which appends stores data to Zend_Auth
object
$auth = Zend_Auth::getInstance();
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable(
$dbAdapter,
'account',
'email',
'password',
'delete_flag=0'
);
//MD5(?) AND .. add this along with the prev where condn of delete flag...
$authAdapter->setIdentity($loginDataArray['email'])
->setCredential($loginDataArray['password']);
$result = $auth->authenticate($authAdapter);
var_dump($result);
if ($result->isValid()) {
$authStorage = $auth->getStorage();
// the details you wan to store in the session
$userDetails = array();
$userDetails['account_id'] = $account_id;
$userDetails['email'] = $loginDataArray['email'];
$authStorage->write($userDetails);
}
Now, How do i append any more data in the later part of the session. How do i edit the same Zend_Auth object later.
해결책
Authentication state is stored in the registered Auth Storage. By default this is Zend_Session. You can get session by this
$namespace = new Zend_Session_Namespace('Zend_Auth');
then do somthing like this
$namespace->newname = "newvalue";
다른 팁
ok, you don't 'edit' Zend_Auth Identity. You either have an identity or not. You can set, read, write or clear storage through the Zend_Auth object.
However many of us use this same data for various display purposes so a solution that often works is to set the data to a different session namespace or a registry key when the identity is being stored or just update the session that Zend_Auth creates as chandresh_ cool suggests.
if ($result->isValid()) {
$authStorage = $auth->getStorage();
// the details you wan to store in the session
$userDetails = array();
$userDetails['account_id'] = $account_id;
$userDetails['email'] = $loginDataArray['email'];
//add user data to registry
$user = Zend_Registry::set('user', $userDetails);
$authStorage->write($userDetails);
}
if you really want to do your own thing you can write your own storage adapter by implementing Zend_Auth_Storage_Interface
or you can write your own Auth adapter by implementing Zend_Auth_Adapter_Interface
and include the storage component in the adapter.
Lots of choices, good luck.