我将Zend_Auth_Storage_Session中的User对象存储为有效身份验证的数组元素。
$authSession = new Zend_Auth_Storage_Session();
$authSession->write(array('user' => $user));
当我读取Zend_Auth_Storage_Session时,用户lastLogin属性是会话写入时的DateTime实例,是字符串。
答案 0 :(得分:1)
cbaby,我不是说这是解决方案,但它对我来说很好,因为我可以正常访问'lastLogin'。也许某处出了别的错误。确保正确设置日期。
$user = new stdClass();
$user->name = 'Mary';
$user->lastLogin= new DateTime();
$authSession = new Zend_Auth_Storage_Session();
$authSession->write(array('user' => $user));
$read = $authSession->read();
echo $read['user']->lastLogin->format('Y-m-d');
echo '<br>' . $read['user']->lastLogin->getTimezone()->getName();