title: Force Laravel to log in a user using legacy authentication
body: <p>I am trying to slowly integrate Laravel into a legacy PHP application. One of the tasks is to automatically register a Laravel user session when a user logs in to the old app. I am not trying to implement Laravel authentication, I really just want to piggyback off of existing functionality and force a specific user to be logged in without checking credentials.  What I have so far has been cobbled together from other people's hacks I have found around:</p>
  
  <pre><code>// Laravel authentication hook - Boostrap application
  require_once getcwd() . '/../laravel/bootstrap/autoload.php';
  $app = require_once getcwd() . '/../laravel/bootstrap/app.php';
  $kernel = $app-&gt;make('Illuminate\Contracts\Console\Kernel');
  $kernel-&gt;bootstrap();
  $app-&gt;boot(); 
  
  // Start Laravel session
  $request = Illuminate\Http\Request::capture();
  $response = $app-&gt;make('Symfony\Component\HttpFoundation\Response');
  $startSession = new Illuminate\Session\Middleware\StartSession($app['session']);
  // Associate server session with the authenticating user id
  // I have also tried loading user model instance and then $app['auth']-&gt;login($user)
  $app['auth']-&gt;loginUsingId($user_id);
  
  $app['session']-&gt;driver()-&gt;start();
  // Terminate middleware response chain with naked response
  $response = $startSession-&gt;handle($request, function() use($response) {
      return $response; // This response will have session cookie attached to it
  });
  
  $response-&gt;send();
  </code></pre>
  
  <p>After this I get a <code>laravel_session</code> cookie that has contents on the client. During the login request after the code above executes, if I <code>dd(Auth::user())</code> then I get the user I just logged in with. However, on subsequent requests <code>Auth::user()</code> and <code>$this-&gt;request-&gt;user()</code>  both return <code>null</code> in all contexts. </p>
  
  <p>How can I force an active Laravel user session without actually authenticating that will persist across requests?</p>
  
  <hr>
  
  <p>The ultimate outcome is that Laravel will be running as a 'sub-application' underneath the legacy app while existing features are pulled in one by one so that both will exist for a period of time until all features are implemented in Laravel and it will replace the existing app in full. If it makes more sense to try to take over the legacy authentication with Laravel rather than the other way around I'm open to that, but I'd rather avoid having to change the underlying users table (legacy authentication is happening over LDAP, so there are no passwords locally, there's no remember_token, but that's easy enough to add if I <em>have</em> to). I really am just looking for the shortest path with the least amount of effort/headache.</p>