【发布时间】:2016-01-06 17:08:16
【问题描述】:
我在读取用户模型中记录的用户会话时遇到困难。
当从任何其他模型中检索用户数据时,它可以完美运行。
模块.PHP
'session' => function ($sm) {
$config = $sm->get('config');
if (isset($config['session'])) {
$session = $config['session']['config']['options']['name'];
//Various Session options
$manager = new \Zend\Session\SessionManager();
if(filter_input(INPUT_SERVER, 'APPLICATION_ENV') === 'production'){
$manager->getConfig()
->setCookieHttpOnly(true)
->setCookieSecure(false);
$manager->start();
}
return new Session($session);
}
},
BaseTable.php
public function getIdentity($property = null) {
$storage = $this->getServiceLocator()->get('session');
if (!$storage) {
return false;
}
$data = $storage->read();
if ($property && isset($data[$property])) {
return $data[$property];
}
return $data;
}
当我调用 tb_usuario 实例化的 getIdentity 函数时,我收到此错误:
致命错误:在非对象上调用成员函数 get() C:\wamp\www\sigaAvaliacoes\module\application\src\Application\Model\BaseTable.php 在第 73 行
对不起我的英语,谢谢!
【问题讨论】:
标签: php session zend-framework2