title: Laravel Auth::attempt function not working
body: <p>I am trying to use the Laravel attempt function within the Auth class to allow a user to login and store themselves in the session. </p>
  
  <p>I understand this function requires an array with the 'password' and 'email' variables and I am sending this fine, it just doesn't seem to be logging me in or returning true.</p>
  
  <p>Here is my controller code:</p>
  
  <pre><code>class LoginController extends BaseController {
      public function login()
      {       
          if(isset($_POST)) {     
              $errorsArray = array();
              foreach($_POST as $key =&gt; $postItem) {
                  if(empty($postItem) || $postItem == "") {
                      $errorsArray[] = array(
                          'errorItem' =&gt; $key,
                          'errorMessage' =&gt; "Please enter a value for " .ucfirst($postItem)
                      );
                  }
              }
              if(!empty($errorsArray)) {
                  $returnArray = array( 
                      'didLog' =&gt; false,
                      'errors' =&gt; $errorsArray 
                  );
              } else {
  
                  if(Auth::attempt(array('username' =&gt; $_POST['username'], 'password' =&gt; $_POST['password']))) {
                      die("here");
                  } else {
                      die("no");
                  }
  
              }
              return json_encode($returnArray);
          }
      }
  
  }
  </code></pre>
  
  <p>As you can see above, I am checking to see if the inputs are valid, and if so, calling the Auth::attempt function in order to log a user in.</p>
  
  <p>The view code:</p>
  
  <pre><code>&lt;form&gt;
          &lt;h3&gt;&lt;i class="lock"&gt;&lt;/i&gt;Please enter your login details&lt;/h3&gt;
          &lt;input type="email" name="username" placeholder="email" data-required=1 /&gt;
          &lt;input type="password" name="password" placeholder="password" data-required=1 /&gt;
          &lt;input type="submit" value="login" /&gt;   
          &lt;button&gt;Signup with Facebook&lt;/button&gt;
          &lt;button&gt;Signup with Twitter&lt;/button&gt;
          &lt;a href="#" class="close-overlay" data-related="login-overlay"&gt;CLOSE&lt;/a&gt;
          &lt;div class="clear"&gt;&lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>And the appropriate Javascript code</p>
  
  <pre><code>            jQuery.ajax({
                  type     : "post",
                  dataType : "json",
                  url      : url,
                  data     : "username=" + username + "&amp;password=" + password,
                  success  : function(data) {
                      if(data.didLog == true) {
                          alert("rrue");
                      } else {
                          alert("false");
                      }
                  }
              });
  </code></pre>
  
  <p>And I have die(print_r(()) the input (which is present in my database) as follows:</p>
  
  <pre><code>Array
  </code></pre>
  
  <p>(
      [username] => jamesholman@bigwavemedia.co.uk
      [password] => password
  )</p>
  
  <p>And the appropriate record in the database</p>
  
  <p><img src="https://i.stack.imgur.com/L1agx.png" alt="enter image description here"></p>
  
  <p>I am getting a "no" (which is a fail in my code) when attempting to login. Can anyone see where I am going wrong as I can't for the life of me figure out why it won't work!
  Thanks</p>