In PHP I often do the following:
$_SESSION['var']['foo'] = array('bar1' => 1, 'bar2' => 2);
// ...
$_SESSION['var']['foo']['bar2'] = 3;
// ...
echo $_SESSION['var']['foo']['bar2']; // 3
I'm wondering what the recommended way of storing multidimensional arrays in a session with Kohana.
I know I can do the following, but I don't know how to make it work with multidimensional, specifically the get portion:
Session::instance()->set('var', array(
'foo' => array(
'bar1' => 1,
'bar2' => 2,
),
));
// ...
// how do I set just bar2?
// ...
// this gets the whole array, but how do I get just bar2?
Session::instance()->get('var');
So, the questions are:
- How do I set just bar2?
- How do I get just bar2?
Is there a way to do either of these in Kohana 3?
I'd love to use the native sessions, but we are trying to use database sessions.