cakephp3 session deprecated

半城伤御伤魂 提交于 2019-12-02 05:04:19

问题


I have update into my project the last version of cakephp core. Now I get this error:

Deprecated (16384): SessionHelper has been deprecated. Use request->session() instead. [CORE/src/View/Helper/sessionHelper.php, line 39]

The error I think is in this line:

if ($this->session->read('admin_logged_in')){

What should I use instead?

Thanks


回答1:


if ($this->request->session->read('admin_logged_in')){

should be fine.

UPDATE

As per the comment of @raph below the correct answer is

$this->request->session()->read('admin_logged_in')

Note the () after session




回答2:


In Cakehp 3.7, use getSession() instead.

$this->request->getSession()->read('admin_logged_in');

Ref: https://book.cakephp.org/3.0/en/development/sessions.html



来源:https://stackoverflow.com/questions/32668754/cakephp3-session-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!