CodeIgniter Forums
Doubt using session - 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: Doubt using session (/showthread.php?tid=2931)



Doubt using session - El Forum - 08-31-2007

[eluser]xernobil[/eluser]
Hi friends, forgives my bad English…

I am with a doubt using sessions, already I searched in forum and I did not find the solution.

The doubt is the following one:

I possess an Array of the following collection:
Code:
$arr = Array('idclient' => $idClient, 'name' => $nameClient);

necessary to insert this Array in one session:
Code:
$this->session->set_userdata('client', $arr);

The doubt is following now:
How I go to have access the value 'name' for example? Using

Code:
$this->session->userdata('name');
it returns emptiness.

Tips?

hug. :cheese:


Doubt using session - El Forum - 08-31-2007

[eluser]xwero[/eluser]
you set the session key to retrieve that array as client so
Code:
$this->session->userdata('client');
gets the array. If you want to extract name you have to do
Code:
$client = $this->session->userdata('client');
echo $client['name'];



Doubt using session - El Forum - 08-31-2007

[eluser]xernobil[/eluser]
simple and efficient! thanks! :cheese: