0
我在閱讀用戶模型中記錄的用戶會話時遇到困難。Zend 2 - 用戶會話不起作用
當從任何其他模型檢索用戶數據時,它可以很好地工作。
MODULE.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;
}
當我打電話getIdentity函數,其中tb_usuario實例我得到這個錯誤:
Fatal error: Call to a member function get() on a non-object in C:\wamp\www\sigaAvaliacoes\module\application\src\Application\Model\BaseTable.php on line 73
對不起我的英語,謝謝!