title: Persisting sessions across subdomains in Laravel 5
body: <p>Using 5.0</p>
  
  <p>in config/session.php I have set <code>'domain' =&gt; '.example.com'</code> but it is not working. I cannot persist a session on even one domain like this.</p>
  
  <p>My site has many subdomains:</p>
  
  <pre><code>vancouver.example.com
  newyork.example.com
  </code></pre>
  
  <p>etc... they are hosted on the same server and are the same Laravel app (share the same storage directory)</p>
  
  <p>I login with the correct credentials, upon which the app redirects to another page on the site, and I have no session at that point. <code>var_dump(Auth::user())</code> shows <code>null</code> even though I logged in with the correct credentials. </p>
  
  <p><code>storage/framework/sessions</code> shows 14 different files there, they are all for me and I cleared them out before I started testing this.</p>
  
  <p>I'll attach my AuthController@postLogin method below, which works fine if session.php <code>'domain' =&gt; null</code></p>
  
  <pre><code>public function postLogin(Request $request)
  {
      $this-&gt;validate($request, [
          'email' =&gt; 'required|email', 'password' =&gt; 'required',
      ]);
  
      $credentials = $request-&gt;only('email', 'password');
  
      if ($this-&gt;auth-&gt;attempt($credentials, $request-&gt;has('remember')))     {
          Session::flash('message', 'You are now logged in.');
          Session::flash('status', 'success');
  
          if (str_contains($_SERVER['HTTP_REFERER'], '?goto=')) {
              $params = explode('?', $_SERVER['HTTP_REFERER'])[1];
              $target = explode('=', $params)[1];
          } else {
              $target = '/';
          }
  
          return redirect($target);
      }
  
      return redirect($this-&gt;loginPath())
                  -&gt;withInput($request-&gt;only('email', 'remember'))
                  -&gt;withErrors([
                      'email' =&gt; $this-&gt;getFailedLoginMessage(),
                  ]);
  }
  </code></pre>