title: Laravel Socialite - Save URL before redirection
body: <p>I'm using <code>Laravel 5.4</code> and <code>Socialite</code> so my users can log in with <code>Facebook</code>.</p>
  <p>My website works with subdomain <code>newyork.example.com</code>, <code>paris.example.com</code> <code>example.com</code></p>
  <p>The <code>Facebook URL</code> redirect for the callback login has to be <code>absolute</code> so I set <code>http://example.com</code></p>
  <h3>login/facebook</h3>
  <pre><code>public function redirectToProvider()
      {
  
          $_SESSION['originalURL'] =&quot;http://paris.example.com&quot;;
  
          return Socialite::driver('facebook')
              -&gt;scopes(['rsvp_event', 'public_profile'])
              -&gt;redirect();
      }
  </code></pre>
  <h3>login/facebook/callback</h3>
  <pre><code> public function handleProviderCallback(SocialAccountService $service)
      {
          $user = $service-&gt;createOrGetUser(Socialite::driver('facebook')-&gt;user());
          // $user-&gt;token;
  
          Auth::login($user, true);
  
          $originalURL = $_SESSION['originalURL'];
  
          return redirect()-&gt;to($originalURL);
      }
  </code></pre>
  <h3>Problems</h3>
  <p>When I am in the <code>route</code> login/facebook I can view the original URL <code>paris.example.com</code> with <code>HTTP_POST</code></p>
  <p>When I am in the route <code>login/facebook/callback</code> the <code>HTTP_POST</code> is <code>example.com</code> since the URL of the redirection is <code>example.com</code>. I tries to save the URL in a <code>session var</code> but <code>$_SESSION</code> is empty.</p>
  <h3>Questions</h3>
  <p>How I can do to get the original url after the facebook login callback redirection. ? So if I started the login process with <code>paris.example.com</code> I'm redirected to <code>example.com</code> and then I get the save url to be redirected</p>
  <h3>sessions.php</h3>
  <pre><code>'cookie' =&gt; 'laravel_session',
  
      /*
      |--------------------------------------------------------------------------
      | Session Cookie Path
      |--------------------------------------------------------------------------
      |
      | The session cookie path determines the path for which the cookie will
      | be regarded as available. Typically, this will be the root path of
      | your application but you are free to change this when necessary.
      |
      */
  
      'path' =&gt; '/',
  
      /*
      |--------------------------------------------------------------------------
      | Session Cookie Domain
      |--------------------------------------------------------------------------
      |
      | Here you may change the domain of the cookie used to identify a session
      | in your application. This will determine which domains the cookie is
      | available to in your application. A sensible default has been set.
      |
      */
  
      'domain' =&gt; env('SESSION_DOMAIN', '.localhost.com'),
  
      /*
      |--------------------------------------------------------------------------
      | HTTPS Only Cookies
      |--------------------------------------------------------------------------
      |
      | By setting this option to true, session cookies will only be sent back
      | to the server if the browser has a HTTPS connection. This will keep
      | the cookie from being sent to you if it can not be done securely.
      |
      */
  
      'secure' =&gt; env('SESSION_SECURE_COOKIE', false),
  
      /*
      |--------------------------------------------------------------------------
      | HTTP Access Only
      |--------------------------------------------------------------------------
      |
      | Setting this value to true will prevent JavaScript from accessing the
      | value of the cookie and the cookie will only be accessible through
      | the HTTP protocol. You are free to modify this option if needed.
      |
      */
  
      'http_only' =&gt; true,
  </code></pre>