0

I'm using Symfony2, and are having trouble getting array values stored in a session, without putting them in a variable or object.

Possible something like:

echo $app['session']->get('shop')->get('name');

Currently I'm achieving it by doing this, but I would like to avoid it for the cause of simplicity:

$temp = $app['session']->get('shop');
echo $temp['name'];

Is it possible?

Thanks in advance

1 Answer 1

4

The session object is just a "parameter bag", an object that holds keys & values.

If you want to create another level of that mechanism you would have to instantiate your own bag.

$shop = new \Symfony\Component\HttpFoundation\ParameterBag;
$shop->set('name', 'Fantastic Warehouse');

$app['session']->set('shop', $shop);

// next request
echo $app['session']->get('shop')->get('name');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.