How to read and write session:
Yes this is the basic question in which I got stuck when I was new to cakephp 3.0. I tried to find out the answer through google, stackoverflow and I finally found the answer to it. In order to read and write sessions in cakephp 3.0, write the following lines of code:
First Method:
Write session by writing following lines of code:
$session = $this->request->session();
$session->write('Config.language', 'eng');
In order to read session :
$session->read('Config.language');
Don't forget to include following lines just before initializing $session
use Cake\Network\Session\DatabaseSession;
Second Method:
Directly read and write session:
$this->request->session()->write('Config.language', 'eng');
$this->request->session()->read('Config.language');
0 Comment(s)