Q:

Codeigniter modifying session data

I store few data in session as the following:
$session_data = array("uid" => "test user", "loged_in" => true);

$this->session->set_userdata($session_data);

To modify the "uid" I tried
$uid = array("uid" => "New user");
$this->session->set_userdata($uid);

It did not work so I tried   
 $this->session->set_userdata("uid","New user");

It also did not work. Cant find any useful stuff on google. Please help how can I change values in the session??

A:

Did you load your session library? $this->load->library('session'); It might be a dumb question but it does not hurt to ask.
What about setting your encryption key? I imagine you would see an error message for that https://www.codeigniter.com/user_guide/libraries/encryption.html
$session_data = array('uid' => 'test user', 'logged_in' => TRUE);
$this->session->set_userdata($session_data);

// modify session
$this->session->set_userdata('uid', 'New user');

