CodeIgniter adding session variable to an already defined "named session" CodeIgniter adding session variable to an already defined "named session" codeigniter codeigniter

CodeIgniter adding session variable to an already defined "named session"


You do as follows in your index() method:

$session_data = $this->session->userdata('verified');$session_data['book_id'] = "something";$this->session->set_userdata("verified", $session_data);

This way you retrieve the contents of the variable (i.e. the array that you persisted earlier), you add another key to the array (book_id), and then store it again. Now you will be able to do, as I assume you want to:

$sess = $this->session->userdata("verified");echo $sess['book_id'];