title: Laravel Auth:attempt() will not persist login
body: <p>I have found many resources online with similar issues but none of the solutions appear to solve my problem.</p>
  <p>When I log a user in with the following code, everything seems fine:</p>
  <pre><code>$email = Input::get('email');
  $password = Input::get('password');
  if (Auth::attempt(array('email' =&gt; $email, 'password' =&gt; $password))) {
      return Auth::user();
  } else {
      return Response::make(&quot;Invalid login credentials, please try again.&quot;, 401);
  }
  </code></pre>
  <p>The <code>Auth::attempt()</code> function returns <code>true</code> and the logged in user is returned to the client using <code>Auth::user()</code>.</p>
  <p>But if the client makes another request to the server directly after, <code>Auth::user()</code> returns <code>NULL</code>.</p>
  <p>I have confirmed that Laravel sessions are working correctly by using the <code>Session::put()</code> and <code>Session::get()</code> successfully.</p>
  <h3>Update</h3>
  <p>On further investigation it appears that sessions are not persisting either! Could this be something to do with having the AngularJS web app server via app.mydomain.com and the Laravel API being served via api.mydomain.com?</p>
  <p>My User model is as follows:</p>
  <pre><code>&lt;?php
  
  use Illuminate\Auth\UserInterface;
  use Illuminate\Auth\Reminders\RemindableInterface;
  
  class User extends Eloquent implements UserInterface, RemindableInterface {
  
      /**
       * The database table used by the model.
       *
       * @var string
       */
      protected $table = 'users';
  
      /**
       * The attributes excluded from the model's JSON form.
       *
       * @var array
       */
      protected $hidden = array('password');
  
      /**
       * Get the unique identifier for the user.
       *
       * @return mixed
       */
      public function getAuthIdentifier()
      {
          return $this-&gt;getKey();
      }
  
      /**
       * Get the password for the user.
       *
       * @return string
       */
      public function getAuthPassword()
      {
          return $this-&gt;password;
      }
  
      /**
       * Get the e-mail address where password reminders are sent.
       *
       * @return string
       */
      public function getReminderEmail()
      {
          return $this-&gt;email;
      }
  
  }
  </code></pre>
  <p>My auth config is as follows:</p>
  <pre><code>&lt;?php
  
  return array(
  
      /*
      |--------------------------------------------------------------------------
      | Default Authentication Driver
      |--------------------------------------------------------------------------
      |
      | This option controls the authentication driver that will be utilized.
      | This driver manages the retrieval and authentication of the users
      | attempting to get access to protected areas of your application.
      |
      | Supported: &quot;database&quot;, &quot;eloquent&quot;
      |
      */
  
      'driver' =&gt; 'eloquent',
  
      /*
      |--------------------------------------------------------------------------
      | Authentication Model
      |--------------------------------------------------------------------------
      |
      | When using the &quot;Eloquent&quot; authentication driver, we need to know which
      | Eloquent model should be used to retrieve your users. Of course, it
      | is often just the &quot;User&quot; model but you may use whatever you like.
      |
      */
  
      'model' =&gt; 'User',
  
      /*
      |--------------------------------------------------------------------------
      | Authentication Table
      |--------------------------------------------------------------------------
      |
      | When using the &quot;Database&quot; authentication driver, we need to know which
      | table should be used to retrieve your users. We have chosen a basic
      | default value but you may easily change it to any table you like.
      |
      */
  
      'table' =&gt; 'users',
  
      /*
      |--------------------------------------------------------------------------
      | Password Reminder Settings
      |--------------------------------------------------------------------------
      |
      | Here you may set the settings for password reminders, including a view
      | that should be used as your password reminder e-mail. You will also
      | be able to set the name of the table that holds the reset tokens.
      |
      | The &quot;expire&quot; time is the number of minutes that the reminder should be
      | considered valid. This security feature keeps tokens short-lived so
      | they have less time to be guessed. You may change this as needed.
      |
      */
  
      'reminder' =&gt; array(
  
          'email' =&gt; 'emails.auth.reminder',
  
          'table' =&gt; 'password_reminders',
  
          'expire' =&gt; 60,
  
      ),
  
  );
  </code></pre>
  <p>The migration used to create the <code>users</code> table is as follows:</p>
  <pre><code>&lt;?php
  
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateUsersTable extends Migration {
  
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('users', function(Blueprint $table)
          {
              $table-&gt;increments('id');
              $table-&gt;string('email')-&gt;unique();
              $table-&gt;string('password');
              $table-&gt;string('first_name');
              $table-&gt;string('last_name');
              $table-&gt;timestamps();
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::table('users', function(Blueprint $table)
          {
              //
          });
      }
  
  }
  </code></pre>
  <p>And the session config:</p>
  <pre><code>&lt;?php
  
  return array(
  
      /*
      |--------------------------------------------------------------------------
      | Default Session Driver
      |--------------------------------------------------------------------------
      |
      | This option controls the default session &quot;driver&quot; that will be used on
      | requests. By default, we will use the lightweight native driver but
      | you may specify any of the other wonderful drivers provided here.
      |
      | Supported: &quot;file&quot;, &quot;cookie&quot;, &quot;database&quot;, &quot;apc&quot;,
      |            &quot;memcached&quot;, &quot;redis&quot;, &quot;array&quot;
      |
      */
  
      'driver' =&gt; 'database',
  
      /*
      |--------------------------------------------------------------------------
      | Session Lifetime
      |--------------------------------------------------------------------------
      |
      | Here you may specify the number of minutes that you wish the session
      | to be allowed to remain idle before it expires. If you want them
      | to immediately expire on the browser closing, set that option.
      |
      */
  
      'lifetime' =&gt; 120,
  
      'expire_on_close' =&gt; false,
  
      /*
      |--------------------------------------------------------------------------
      | Session File Location
      |--------------------------------------------------------------------------
      |
      | When using the native session driver, we need a location where session
      | files may be stored. A default has been set for you but a different
      | location may be specified. This is only needed for file sessions.
      |
      */
  
      'files' =&gt; storage_path().'/sessions',
  
      /*
      |--------------------------------------------------------------------------
      | Session Database Connection
      |--------------------------------------------------------------------------
      |
      | When using the &quot;database&quot; or &quot;redis&quot; session drivers, you may specify a
      | connection that should be used to manage these sessions. This should
      | correspond to a connection in your database configuration options.
      |
      */
  
      'connection' =&gt; null,
  
      /*
      |--------------------------------------------------------------------------
      | Session Database Table
      |--------------------------------------------------------------------------
      |
      | When using the &quot;database&quot; session driver, you may specify the table we
      | should use to manage the sessions. Of course, a sensible default is
      | provided for you; however, you are free to change this as needed.
      |
      */
  
      'table' =&gt; 'sessions',
  
      /*
      |--------------------------------------------------------------------------
      | Session Sweeping Lottery
      |--------------------------------------------------------------------------
      |
      | Some session drivers must manually sweep their storage location to get
      | rid of old sessions from storage. Here are the chances that it will
      | happen on a given request. By default, the odds are 2 out of 100.
      |
      */
  
      'lottery' =&gt; array(2, 100),
  
      /*
      |--------------------------------------------------------------------------
      | Session Cookie Name
      |--------------------------------------------------------------------------
      |
      | Here you may change the name of the cookie used to identify a session
      | instance by ID. The name specified here will get used every time a
      | new session cookie is created by the framework for every driver.
      |
      */
  
      '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; null,
  
      /*
      |--------------------------------------------------------------------------
      | 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; false,
  
  );
  </code></pre>
  
  <p>Any ideas?</p>