I am working on an application using zend framework 2 session array containers. I can create the session using array containers as mentioned in zend 2 document, but i am getting the problem while creating the session with multidimensional arrays. I want to update the session everytime since i am updating the values for shopping cart. I am trying with the below code, its not updated rather the session values are getting changed.
$container = new Container('test');
$values = array();
$values['one'] = '1';
$values['two'] = '2';
$container->item = $values; // Now the session contains the $values array 1,2
$container = new Container('test');
$values['one'] = '3';
$values['two'] = '4';
$container->item = $values; // Here the session values are 3,4 and 1,2 is not updating
I tried also with OffsetGet and OffsetSet methods as below, but the session values are not updated.
$container = new Container('test');
$session = $container->offsetGet('item');
$values['one'] = '3';
$values['two'] = '4';
$session = $container->offsetSet('item', $values); // results are 3,4
I am expecting the results as below,
Array
(
[0] => Array
(
[values] => Array
(
[one] => 1
[two] => 2
)
)
[1] => Array
(
[values] => Array
(
[one] => 3
[two] => 4
)
)
)
How i can obtain the multidimensional session arrays in zend 2 ? Thanks.