Welcome Guest, Not a member yet? Register   Sign In
Retrieving data using the Session class - What if the index is an array?
#1

[eluser]callumd[/eluser]
I'm using CodeIgniter's Session class, and I now need to access an array of data that is in it.

I need to do the equivalent of:

echo $this->session->userdata("family['brother']");

.. where "family" is an array containing indexes like 'brother', 'sister', 'mother' etc.

But this doesn't work, nor does any other combination I can think of and have tried.

Help?
#2

[eluser]Roy MJ[/eluser]
Try this in controller...

$anyname= array( 'field1' => $field1,
'field2' => $field2,
.
.
.
);
$this->session->set_userdata($anyname);

$this->data['field1'] = $field1;
#3

[eluser]callumd[/eluser]
Thanks Roy,

I'm surprised it has to work like this, though.

Callum.
#4

[eluser]Roy MJ[/eluser]
:p.. hehe.. I have been using this way though... Hope it worked according to your need....




Theme © iAndrew 2016 - Forum software by © MyBB