CodeIgniter Forums
How to edit particular value in session table? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to edit particular value in session table? (/showthread.php?tid=53604)



How to edit particular value in session table? - El Forum - 07-31-2012

[eluser]peekk[/eluser]
Hello,
when I type
Code:
print_r($this->session->all_userdata());
it shows

Code:
[user_data] => [search_conditions] => Array ( [aaa] => value1, [bbb] => value2 ) )


I want to change only the value of 'aaa' index in search_conditions table (example: 'value1' into 'changed_value1' - how to do it?


How to edit particular value in session table? - El Forum - 07-31-2012

[eluser]CroNiX[/eluser]
Code:
//Get the key 'search_conditions' data from session
$data = $this->session->userdata('search_conditions');

//Overwrite the value for 'aaa' (should currently be Array ( [aaa] => value1, [bbb] => value2 ))
$data['aaa'] = 'changed_value1';

//store it back in session using 'search_conditions' as the key
$this->session->set_userdata('search_conditions', $data);