title: How To Get Array From Session Object In Kohana?
body: <p>I'm using Kohana 3.0 and I need to get array from <code>Session</code> object.</p>
  
  <p>For example:</p>
  
  <pre><code>$session = Session::instance();
  
  $session-&gt;set(
      'myArray'
      array(
          'key1' =&gt; 'foo',
          'key2' =&gt; 'bar'
      )
  );
  
  // How to get specific array element?
  </code></pre>
  
  <p>I thought that this will work, but it returned <code>null</code>.</p>
  
  <pre><code>$session-&gt;get('myArray.key2');
  </code></pre>
  
  <p>After thinking and thinking (ha, ha!) I think-out this...</p>
  
  <pre><code>$myArray = $session-&gt;get('myArray');
  $key1 = $myArray['key1'];
  </code></pre>
  
  <p>Is it okay? Is there better way?</p>
  
  <p>P.S. When <a href="http://it2.php.net/migration55.new-features#migration55.new-features.const-dereferencing" rel="nofollow">array dereferencing</a> will be available... gonna use it! =]</p>
  
  <pre><code>$key1 = $session-&gt;get('myArray')['key1']; // Lets hope that this work!
  </code></pre>