title: Laravel Authentication - User can not login even the credentials are right and exactly the same from the database
body: <p>I'm creating a new project and after creating all the needed modules for the authentication of the system, I cannot log in and go to the right page and it always redirects to login page even though the login credentials are right and exactly the same from the database. Here are the codes. Please help me to know exactly what and where did I go wrong, thank you in advance.</p>
  
  <blockquote>
    <p>Controller
        
  </blockquote>
  
  <pre><code>namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use Validator;
  use Auth;
  
  class AuthController extends Controller
  {
      function index() {
          return view('auth/login');
      }
  
      function checklogin(Request $request) {
          $this-&gt;validate($request, [
              'username'=&gt;'required|email',
              'password'=&gt;'required|min:6'
          ]);
  
          $user_data = array(
              'username'=&gt;$request-&gt;get('username'),
              'password'=&gt;$request-&gt;get('password')
          );
  
          if(Auth::attempt($user_data)) {
              return redirect('personnel');
          }else {
              return back()-&gt;with('error', 'Wrong Login Details');
          }
      }
  
      function successlogin() {
          return view('personnel');
      }
  
      function logout() {
          Auth::logout();
          return redirect('auth');
      }
  }
  </code></pre>
  
  <blockquote>
    <p><strong>login.blade.php</strong></p>
  </blockquote>
  
  <pre><code>@extends('layouts.general-master')
  
  @section('title', 'Login')
  
  @section('content')
  &lt;div class="header align-left general-header"&gt;{{ __('Login') }}&lt;/div&gt;
  &lt;div class="body"&gt;
      @if(isset(Auth::user()-&gt;username))
          &lt;script&gt;window.location = "/personnel";&lt;/script&gt;
      @endif
  
      @if($message = Session::get('error'))
          &lt;div class="alert alert-danger alert-block"&gt;
              &lt;button type="button" class="close" data-dismiss="alert"&gt;x&lt;/button&gt;
              &lt;strong&gt;{{ $message }}&lt;/strong&gt;
          &lt;/div&gt;
      @endif
  
      @if(count($errors) &gt; 0)
          &lt;div class="alert alert-danger"&gt;
              &lt;ul&gt;
                  @foreach($errors-&gt;all() as $error)
                      &lt;li&gt;{{ $error }}&lt;/li&gt;
                  @endforeach
              &lt;/ul&gt;
          &lt;/div&gt;
      @endif
      &lt;form method="POST" action="{{ url('/auth/checklogin') }}"&gt;
          @csrf
  
          &lt;div class="form-group row"&gt;
              &lt;label for="username" class="col-md-4 col-form-label text-md-right"&gt;{{ __('Username') }}&lt;/label&gt;
  
              &lt;div class="col-md-6"&gt;
                  &lt;input id="username" type="email" class="form-control{{ $errors-&gt;has('username') ? ' is-invalid' : '' }} general-input" name="username" value="{{ old('username') }}" required autofocus&gt;
  
                  @if ($errors-&gt;has('username'))
                      &lt;span class="invalid-feedback" role="alert"&gt;
                          &lt;strong&gt;{{ $errors-&gt;first('username') }}&lt;/strong&gt;
                      &lt;/span&gt;
                  @endif
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group row"&gt;
              &lt;label for="password" class="col-md-4 col-form-label text-md-right"&gt;{{ __('Password') }}&lt;/label&gt;
  
              &lt;div class="col-md-6"&gt;
                  &lt;input id="password" type="password" class="form-control{{ $errors-&gt;has('password') ? ' is-invalid' : '' }} general-input" name="password" required&gt;
  
                  @if ($errors-&gt;has('password'))
                      &lt;span class="invalid-feedback" role="alert"&gt;
                          &lt;strong&gt;{{ $errors-&gt;first('password') }}&lt;/strong&gt;
                      &lt;/span&gt;
                  @endif
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group row"&gt;
              &lt;div class="col-md-6 col-md-push-2"&gt;
                  &lt;div class="form-check"&gt;
                      &amp;emsp;&amp;emsp;
                      &lt;input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}&gt;
                      &lt;label class="form-check-label" for="remember"&gt;
                          {{ __('Remember Me') }}
                      &lt;/label&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group row mb-0"&gt;
              &lt;div class="col-md-8 col-md-push-2"&gt;
                  &amp;emsp;
                  &lt;button type="submit" class="btn btn-primary"&gt;
                      {{ __('Login') }}
                  &lt;/button&gt;
  
                  @if (Route::has('password.request'))
                      &lt;a class="btn btn-primary col-white" href="{{ route('password.request') }}"&gt;
                          {{ __('Forgot Your Password?') }}
                      &lt;/a&gt;
                  @endif
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  @endsection
  </code></pre>
  
  <blockquote>
    <p><strong>person.blade.php -- this is the right page to go after logging in</strong></p>
  </blockquote>
  
  <pre><code>@extends('layouts.master')
  
  @section('title', 'Personnel Management')
  
  @section('content')
      @if(isset(Auth::user()-&gt;username))
          &lt;section class="content"&gt;
              &lt;div class="container-fluid"&gt;
                  &lt;div class="block-header"&gt;
                      &lt;h2 class="align-center"&gt;
                          PERSONNEL MANAGEMENT
                      &lt;/h2&gt;
                  &lt;/div&gt;            
  
                  &lt;div class="row clearfix"&gt;
                      &lt;div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"&gt;
                          &lt;div class="card"&gt;
                              &lt;div class="header"&gt;
                                  &lt;button type="button" class="btn bg-blue waves-effect" data-toggle="modal" data-target="#addPersonnelModal"&gt;
                                      &lt;i class="material-icons"&gt;add&lt;/i&gt;
                                      &lt;span&gt;ADD PERSONNEL&lt;/span&gt;
                                  &lt;/button&gt;
                                  &lt;input type="text" id="txtSearchPerKey" name="txtSearchPerKey"&gt;
                                  &lt;span id="spanSearchPerKey"&gt;Search: &lt;/span&gt;
                              &lt;/div&gt;
                              &lt;div class="body"&gt;
                                  &lt;div class="table-responsive"&gt;
                                      &lt;table id="tblViewPersonnels" class="table table-bordered table-striped table-hover"&gt;
                                          &lt;thead&gt;
                                              &lt;tr&gt;
                                                  &lt;th class="align-center"&gt;Name&lt;/th&gt;
                                                  &lt;th class="align-center"&gt;Position&lt;/th&gt;
                                                  &lt;th class="align-center"&gt;Action&lt;/th&gt;
                                              &lt;/tr&gt;
                                          &lt;/thead&gt;
                                          &lt;tfoot&gt;
                                              &lt;tr&gt;
                                                  &lt;th class="align-center"&gt;Name&lt;/th&gt;
                                                  &lt;th class="align-center"&gt;Position&lt;/th&gt;
                                                  &lt;th class="align-center"&gt;Action&lt;/th&gt;
                                              &lt;/tr&gt;
                                          &lt;/tfoot&gt;
                                          &lt;tbody&gt;
                                              &lt;!-- code will be generated here --&gt;
                                          &lt;/tbody&gt;
                                      &lt;/table&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/section&gt;
      else
          &lt;script&gt;window.location = "/auth";&lt;/script&gt;
      @endif
  @endsection
  </code></pre>
  
  <blockquote>
    <p><strong>web.php -- here are the routes</strong></p>
  </blockquote>
  
  <pre><code>Auth::routes();
  
  Route::get('/home', 'HomeController@index')-&gt;name('home');
  </code></pre>
  
  <blockquote>
    <p><strong>LOGIN</strong></p>
  </blockquote>
  
  <pre><code>Route::get('/auth', 'AuthController@index');
  Route::post('/auth/checklogin', 'AuthController@checklogin');
  Route::get('/auth/logout', 'AuthController@logout');
  </code></pre>
  
  <blockquote>
    <p><strong>PERSONNEL</strong></p>
  </blockquote>
  
  <pre><code>Route::get('/personnel', function () {
      return view('personnel');
  });
  </code></pre>