Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Discussion on read and write Session in Cakephp 3.0

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 196
    Comment on it

    Hi Reader's,
    Welcome to FindNerd, today we are going to discuss on read and write Session in Cakephp 3.0

    Sessions is used for allowing you to identify unique users and session also allow to you requests and store persistent data for specific users.

    If you want use read and write session in your web application and you are using Cakephp 3.0, Then you have to follow below methods.

    There are two methods for using read and write Session in Cakephp 3.0.

    Note :- Firstly you have to include following lines

    use Cake\Network\Session\DatabaseSession;

    1-Write session :
    In this method you have to set $session :
    you can see below code for better understanding

    <?php
        $session = $this->request->session();
        $session->write('Config.language', 'eng'); 
     ?>

    For read session you can see below code:

    <?php  $session->read('Config.language'); ?>

    After set session you can read and write in your session.

     2- Directly read and write session:
     In second method you can use read and write session directly like below code:

    <?php
        $this->request->session()->write('Config.language', 'eng');
        $this->request->session()->read('Config.language');
    ?>

    I hope this blog will help you to read and write Session in Cakephp 3.0.

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
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: