title: Share Laravel authentication/session with PHP
body: <p>I'm trying to use Laravels authentication with a number of simple HTML/Javascript applications. </p>
  
  <p>The way I think it would ideally work is this:</p>
  
  <ol>
  <li>The user visits the simple HTML application</li>
  <li>The simple HTML application includes a PHP file which checks if a
  user is authenticated. If this is not the case the user is sent to
  the Laravel application to login, if the user is logged in he can simply use the application.</li>
  <li>The user logs in through Laravel and is redirected back to the HTML application where this process will start over again.</li>
  </ol>
  
  <p>The problem I have is checking whether a user is logged in the PHP script. Laravels session is not available there (and sharing it through <code>session_start()</code> and <code>$_SESSION["auth"] = true</code> will only add the variable to Laravels version of the native PHP session).</p>
  
  <p>These are the settings I have in <code>app/config/session.php</code></p>
  
  <pre><code>return array(
      'driver' =&gt; 'native',
      'lifetime' =&gt; 120,
      'files' =&gt; storage_path().'/sessions',
      'connection' =&gt; null,
      'table' =&gt; 'sessions',
      'lottery' =&gt; array(2, 100),
      'cookie' =&gt; 'laravel_session',
      'path' =&gt; null,
      'domain' =&gt; null,
  
  );
  </code></pre>
  
  <p>I've changed the path to <code>null</code> because I want to use the session on the entire domain.</p>
  
  <p>My included PHP script is very simple and looks like this:</p>
  
  <pre><code>session_start();
  
  if($_SESSION['authenticated']){
      echo "logged_in";
  } else {
      header("Location: laravel/login/url");
  }
  </code></pre>
  
  <p>You might wonder why I don't just include the application in Laravels framework, it's because there are about 100 different versions of this simple HTML application scattered over 10 domain names, at the moment every domain name has it's own (very old and insecure) login script (which is copied every time a new domain gets made). Therefor I want to centralize this with one database and one management system using Laravel.</p>
  
  <p>Hopefully someone here knows how to fix this problem or work around it (maybe I should try to use Laravels session package in my PHP script?).</p>