title: Laravel session key changing the whole time?
body: <p>I am using "file storage" for my session. When I run this:</p>
  
  <pre><code>Session::set('awesomekey', 'myVal123');
  </code></pre>
  
  <p>And refresh the page, I can see new files being created in /storage/session each time. I assumed it would update the same file each time. This basically means sessions don't work at all. In other words, if it keeps recreating a session file, this never works:</p>
  
  <pre><code>Session::get('awesomekey');
  </code></pre>
  
  <p>Or at least, it returns a blank. What am I missing that could possibly be causing a new session key to be created each time a page is loaded?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>On further investigation, it seems the cookie is regenerated on each page load. What could be causing that?</p>
  
  <p>I am not even looking at logging in yet, so this information is useless to me --> <a href="http://willworkforbanjos.com/2014/02/laravel-sessions-not-working-in-4-1/">http://willworkforbanjos.com/2014/02/laravel-sessions-not-working-in-4-1/</a> </p>
  
  <p>My problem is happening when I simply put the above set and get code in the master.blade.php file. It should set it, store the info, and on the next reload get the right information from session. But it can't because on reload it changed the cookie to some other code.</p>
  
  <p>Anyone know why this is happening?</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <ol>
  <li>Adding: 'lifetime' => 120 to session.php did not work. (@Sheikh Heera)</li>
  <li>Placing the code in the controller only, does not work. (@Phill Sparks)</li>
  <li>I tried chrome and firefox, same result (@The Shift Exchange)</li>
  </ol>
  
  <p>Just to be clear on what I'm trying to do. I add the following code in HomeController.php:</p>
  
  <pre><code>public function index()
  {
      Session::put('awesomekey', 'myVal123');
      return View::make('home.index');
  }
  </code></pre>
  
  <p>Then I put this in my master.blade.php:</p>
  
  <pre><code>print Session::get('awesomekey');
  </code></pre>
  
  <p>I do not include any "dies" or random echos in my controller side of the code, except for this. When I open the file the first time, I can see myVal123 being printed out. </p>
  
  <p>I then take out this part in the controller:</p>
  
  <pre><code>Session::put('awesomekey', 'myVal123');
  </code></pre>
  
  <p>And reload the page. It now prints nothing. I can see in my browser that the cookie has changed. Generating a new cookie will lose the reference to the session, so I'm stuck trying to understand why it's doing that each time, even though it saves the session on the first load.</p>
  
  <p>Any more ideas?</p>
  
  <p><strong>UPDATE 3</strong></p>
  
  <p>I also tried:</p>
  
  <ol>
  <li>Running "php artisan dump-autoload" ... still doesn't work</li>
  <li>I went here: <a href="http://www.whatismybrowser.com/are-cookies-enabled">http://www.whatismybrowser.com/are-cookies-enabled</a> ... and yes, cookies are enabled.</li>
  </ol>
  
  <p>I'm really running out of ideas here...</p>
  
  <p><strong>UPDATE 4</strong></p>
  
  <ol>
  <li><p>I went to SessionManager.php and just underneath this:</p>
  
  <p>$lifetime = $this->app['config']['session.lifetime'];</p></li>
  </ol>
  
  <p>I printed out the value of life time:</p>
  
  <pre><code>print $lifetime; die();
  </code></pre>
  
  <p>And this code was never hit on page reload?! However, adding this in my controller:</p>
  
  <pre><code>$d = Config::get('session.lifetime');
  print $d;
  </code></pre>
  
  <p>Does in fact print out my value for lifetime.... :(</p>