Welcome Guest, Not a member yet? Register   Sign In
Multi-dimensional Session array
#1

[eluser]kerell78us[/eluser]
I wish to store some session data as a multi-dimensional array however, I am not sure how to reading the stored data using the
Code:
$this->session->userdata('member')
e.g.

Code:
$users = array();

$colors = array('red', 'blue', 'orange', purple');

foreach($users as $key => $user) {
   $members[$key] = array(
          'user_id' => $user['user_id'],
          'colors' = $colors);

}
To set the session data with the following line of code...
Code:
$this->session->set_userdata('member', $members);

My question is how do I retrieve the 'colors' array for a particular user from the session data for that user?
#2

[eluser]WanWizard[/eluser]
A session exists per user, so why are you storing information of multiple users?

Other than that, your code is correct. And you retrieve it the way you stored it:
Code:
$userid = 1;
$members = $this->session->userdata('members');
$colors = $members[$userid]['colors'];
#3

[eluser]kerell78us[/eluser]
Thanks...




Theme © iAndrew 2016 - Forum software by © MyBB