How to read and write Session in Cakephp 3.0
You need to set $session :
$session = $this->request->session();
$session->write('Config.language', 'eng');
$session->read('Config.language');
And then you'll be able to read and write in your session
Or you can direclty read and write :
$this->request->session()->write('Config.language', 'eng');
$this->request->session()->read('Config.language');
Version 3.6.0 and above use getRequest()
and getSession()
Document.
$name = $this->getRequest()->getSession()->read('User.name');
And if you are accessing the session multiple times, you will probably want a local variable.
$session = $this->getRequest()->getSession();
$name = $session->read('User.name');
I use this its works fine
$session = $this->request->session();
$session->write('annul_income','$100,00,00');//Write
echo $session->read('annul_income')//To read the session value o/p:$100,00,00