CodeIgniter Forums
Unable to store data into the session in 3.1.8 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Unable to store data into the session in 3.1.8 (/showthread.php?tid=70765)



Unable to store data into the session in 3.1.8 - sumanta.sharma007 - 05-27-2018

Hi people

I am unable to store the data in the session. I have already started the session in autoloaders but the session is not storing the data which I am unable to find in the next page/controller.

Please help me 
there is my code

/
Code:
/= from here i am storing the data into the session (controller name: login)
public function demo(){
                $array = array('email'=>'[email protected]');
                $this->session->set_userdata('email');
                redirect(base_url().'user/demo');

        }



Code:
//= here i am printing it. (controller name: user)
public function demo(){
        echo $this->session->userdata('email');
    }



RE: Unable to store data into the session in 3.1.8 - skunkbad - 05-27-2018

Show your session config


RE: Unable to store data into the session in 3.1.8 - ciadmin - 05-27-2018

$this->session->set_userdata('email'); won't do much
You *could* do $this->session->set_userdata($array);, which will save the email address as the value for the key 'email'.
Or you could $this->session->set_userdata('email', $array['email');

You are not using sessions correctly.
https://www.codeigniter.com/user_guide/libraries/sessions.html#adding-session-data