• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating a session array

#1
I would like to update a session array using the codeigniter session library terminology.

I have a session array named chairs. Each key of the array is the chairID of the associated chair and the value of the chairID key is the quantity of chairs of with that ID.


I am looking at how I can update the array to add chairs to the array. 


I know the php syntax (bold). Below it is a list of possible codeigniter session library approaches I've postulated. They are probably all incorrect, I would appreciate some guidance.


$_SESSION['chairs'][$chairID] = $chairQuant;
               
$this->sesison->chairs[$chairID] = $chairQuant; (Simply replacing $_SESSION['chairs'] with $this->sesison->chairs)
               
$this->session->chairs += [$chairID => $chairQuant] (using unary array union operator)
                
{


$array = $this->session->chairs; 
               
array_push($array, array($chairID => $chairQuant))
               
$this->session->set_userdata(chairs, $array);


}  (Seemingly the most terminologically faithful approach, assign the session array value to another array, update this array using the array_push, then set the session array with the value of this new array. This approach feels very long winded, considering the alternative(s).)

Would appreciate help!

Thanks

God bless.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.