Using Laravel 5 Sessions Externally
<p>I've figured out how to boot Laravel in an external script, but I can't seem to get Session::put() to stick. </p>

<pre><code>$path = "/path/to/laravel/bootstrap/";

require $path . 'autoload.php';
$app = require_once $path . 'app.php';

$app-&gt;make('Illuminate\Contracts\Http\Kernel')
  -&gt;handle(Illuminate\Http\Request::capture());

print_r(Session::all());
Session::put('test', 1);
</code></pre>

<p>Even after I refresh, this is the output:</p>

<pre><code>Array ( 
    [_token] =&gt; emt8sZz7U6prnGUnHV889XPKwuhRCuMpVsAOfWW0 
    [flash] =&gt; Array ( 
        [old] =&gt; Array ( ) 
        [new] =&gt; Array ( ) 
    ) 
    [_previous] =&gt; Array ( 
        [url] =&gt; http://myurl.local  
    )
)
</code></pre>

<p>With no trace of my test variable. For some reason it doesn't make it into the Session. </p>

<p><strong>SOLUTION:</strong></p>

<p>Looks like I needed to call Session::save(). New problem below.</p>

<p><strong>NEW PROBLEM:</strong></p>

<p>I discovered that Laravel sessions work great when there is already a session in place. When there is no session, this approach does not create a new session. Specifically, the cookie (laravel_session) is not set.</p>

<p>Any ideas?</p>