0
這是我在我的視圖代碼:會話視圖助手CakePHP3
if($this->request->session->read('Auth.User')) {
echo $this->Html->link('Log Out', array('controller' => 'users','action' => 'logout'));
}
if(!$this->request->session->read('Auth.User')) {
echo $this->Html->link('Log Out', array('controller' => 'users','action' => 'logout'));
}
但我得到這個錯誤:
Call to a member function read() on null
我連接,但不工作。
你有沒有在控制器中使用'Cake \ View \ Helper \ SessionHelper'? –
@MohdSayeed是在我的AppController –
試試這個'$ this-> request-> session() - > read('Auth.User')'在這裏你有[更多信息](http://book.cakephp.org /3.0/en/development/sessions.html#accessing-the-session-object) –