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.
}
有任何想法吗?     
已邀请:
发生这种情况的原因是,在请求之间对“ 4”个身份数据进行了序列化(和反序列化)。 这使我们更仔细地研究了
Zend_Db_Table_Row_Abstract
类的
__sleep
方法,这是在
$user
对象被序列化后被调用的方法。
public function __sleep()
{
    return array(\'_tableClass\', \'_primary\', \'_data\', \'_cleanData\', \'_readOnly\' ,\'_modifiedFields\');
}
您需要做的是在
Person
类中重写此方法,以便它也包含
$_cdata
数组。然后,此属性将被序列化,并在下一个HTTP请求中可用。     

要回复问题请先登录注册