title: Why my CORS application doesn't recognize my session?
body: <p>I've been trying to setup CORS in my Angular client-side and Laravel server-side app, in order to debug it. I've done it before without problems, but for an extraneous reason this is not working now, and I don't know why.</p>
  
  <p>I tried using <a href="https://github.com/barryvdh/laravel-cors" rel="nofollow noreferrer">laravel-cors</a> and now I'm trying with a custom middleware in Laravel, anyways the result is exactly the same.</p>
  
  <p>I can send CORS petitions to the server, and I can login into. But once I'm there, the server is not able to detect that I'm already logged in.</p>
  
  <p>I've already set the following in my angular application. (In fact I never did this with my other apps, but read that I might need the following).</p>
  
  <pre><code>app.config(function ($httpProvider) {
      $httpProvider.defaults.withCredentials = true;
      $httpProvider.defaults.useXDomain = true;
  });
  </code></pre>
  
  <p>But I keep getting a 302 response (redirect) from Laravel to the OPTIONS request sent by the Angular app. Meaning that I'm not logged into the app (which in fact I did).</p>
  
  <p>An image explains it better, here's the <strong>failed authentication with CORS</strong>:
  <a href="https://i.stack.imgur.com/Ncq95.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ncq95.jpg" alt="Failed CORS"></a></p>
  
  <p>And here is the <strong>working authentication with CORS</strong> (I think I did mostly the same in both, but one works and the other don't):
  <a href="https://i.stack.imgur.com/ZcAid.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZcAid.jpg" alt="Working CORS"></a></p>
  
  <p>I should add that this is not a session problem, as this works without CORS (On a Webview).</p>