Zend Session Identity丢失对象参数
|
我有一个奇怪的问题,我似乎无法追查。
我有一个自定义类(\“ Person \”),它扩展了代表用户的Zend_Db_Table_Row_Abstract。
除其他外,此类具有在init()方法中设置的自定义变量,例如:
class Person extends Zend_Db_Table_Row_Abstract
{
protected $_cdata = array(); // non-db-table data gets put here through __set()
public function init()
{
$this->fullName = $this->firstName.\" \".$this->lastName; // this is saved to $this->_cdata[\'fullName\']
}
登录后,我将此类的对象存储为Zend Auth Identity:
$r = $auth->authenticate($authAdapter);
if($r->isValid())
{
$user = $db->getUserByEmail($email); // Retrieves an object of class \"Person\"
$auth->getStorage()->write($user);
}
现在,如果我在与登录相同的操作请求中调用身份验证,那么它将正常工作:
echo $user->fullName; // Will print \"John Smith\" or whatever it is
但是,当我调用另一个操作并调用“身份验证”时,将丢失我存储在“ _cdata \”数组中的所有内容:
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity() {
$user = $auth->getIdentity();
echo $user->fullName; // Prints nothing...$_cdata[\'fullName\'] does not exist.
}
有任何想法吗?
没有找到相关结果
已邀请:
1 个回复
澳绍能
类的
方法,这是在
对象被序列化后被调用的方法。
您需要做的是在
类中重写此方法,以便它也包含
数组。然后,此属性将被序列化,并在下一个HTTP请求中可用。