title: Laravel Session variables in Blade @if
body: <p>I've hit some weirdness with Laravel 4.2 when trying to set a JS variable in a blade using Laravel Session to flash some data. It's pretty simply, and I can't figure out what I've missed...</p>
  
  <p>Goal: trigger a Javascript website tour right after a user registers.
  Approach: Flash a welcome_tour variable to session, which then sets a JS boolean when the page refreshes which in turn starts the tour in JS.</p>
  
  <p>My register function concludes with the Session setting:</p>
  
  <pre><code>Session::flash('welcome_tour', TRUE);
  </code></pre>
  
  <p>And I'm testing that it's picked up and sets the JS variable correctly with the following in my blade:</p>
  
  <pre><code>&lt;script&gt;
      @if(Session::has('welcome_tour'))
          var welcome_tour = true;
      @else
          var welcome_tour = false;
      @endif
  &lt;/script&gt;
  {{ var_dump(Session::all()) }}
  </code></pre>
  
  <p>The JS snippet in the resulting HTML indicates that the welcome_tour was not found :-(</p>
  
  <pre><code>&lt;script&gt;
      var welcome_tour = false;
  &lt;/script&gt;
  </code></pre>
  
  <p>But the Session detail printed to the screen by the var_dump indicates that it was set correctly:</p>
  
  <pre><code>array (size=4)
    '_token' =&gt; string 'HHBowu6wdYlIKy4kFiWYwCe4lQRkFbG7jdNDlYXQ' (length=40)
    'flash' =&gt; 
      array (size=2)
        'old' =&gt; 
          array (size=1)
            0 =&gt; string 'welcome_tour' (length=12)
        'new' =&gt; 
          array (size=0)
            empty
    'login_82e5d2c56bdd0811318f0cf078b78bfc' =&gt; string '1137' (length=4)
    'welcome_tour' =&gt; boolean true
  </code></pre>
  
  <p>How can the Session variable be both there and not there??</p>