简体   繁体   中英

cakephp3 session deprecated

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM