CodeIgniter Forums
Storing and Retrieving Session Data - 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: Storing and Retrieving Session Data (/showthread.php?tid=58067)



Storing and Retrieving Session Data - El Forum - 05-11-2013

[eluser]maddtechwf[/eluser]
I've looking through the manual trying to figure out how to store data in the Session and then retrieve it and show it when I need to. I have the session library initiated in the autoload file. I just can't figure out how to write data to it.


Storing and Retrieving Session Data - El Forum - 05-11-2013

[eluser]maddtechwf[/eluser]
Okay, so I figured out my initial issue. I wasn't using set_userdata. I have an array that is returned when a username and email address is verified in my database, how can I access specific data out of the array? Lets say that I have an array called $res and it have 6 values in the array. I'm trying to pull a specific item out of the array and storing it in my session data using set_userdata.


Storing and Retrieving Session Data - El Forum - 05-13-2013

[eluser]boltsabre[/eluser]
Quote:how can I access specific data out of the array?
By its array key

Quote:I’m trying to pull a specific item out of the array and storing it in my session data using set_userdata.
$this->session->set_userdata('email', $res['email']);

Check out the official CI documentation if you haven't already:
http://ellislab.com/codeigniter/user-guide/libraries/sessions.html