title: How to add items in Laravel session array
body: <p>I'm using Laravel 4.2. I have a method for storing files and  I'm trying to push items in session array. Every time user clicks on a button, I want to save these file names in session array with a name and later I should get them. </p>
  
  <p>I'm trying with the following code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$name = Input::get('name');
  $input = Input::all();
  foreach ($input[$name] as $key =&gt; $corporate) {
  
    $file_name = $key.'_'.$current_time . '_' . $corporate-&gt;getClientOriginalName();
    //code for uploading files
    if(Session::has($name)) {
       Session::push($name.".".$key, $file_name); //I want to add new items in this array
    } else {
      Session::put($name, $file_name); //for first image
    }
  
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>As I read from laravel docs:</p>
  
  <blockquote>
    <p>Push A Value Onto An Array Session Value</p>
    
    <p>Session::push('user.teams', 'developers');</p>
  </blockquote>
  
  <p>);`</p>
  
  <p>But it doesn't add new items to array, it overwrites it.</p>
  
  <p>After first image upload in session array I have:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>["director_front_passport[]"]=&gt;
    array(1) {
      [1]=&gt;
      array(1) {
        [0]=&gt;
        string(54) "0_1472669237_12894473_678457885627912_1258115018_o.jpg"
      }
    }</code></pre>
  </div>
  </div>
  </p>
  
  <p>After uploading second image, session is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>["director_front_passport[]"]=&gt;
    array(1) {
      [2]=&gt;
      array(1) {
        [0]=&gt;
        string(33) "0_1472669255_animated_loading.gif"
      }
    }</code></pre>
  </div>
  </div>
  </p>
  
  <p>What is the proper way to push items in session array with definite name, I mean I should get these items later using: Session::get('name') for example.</p>