Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Cakephp 3.0: How to read and write Session

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.26k
    Comment on it

    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 :




    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');


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: