419 Page Expired Laravel 5.8 - After Login

Karthik picture Karthik · Sep 3, 2019 · Viewed 15.3k times · Source

I Created one Project in Laravel 5.8. In my Local Environment(PHP 7.2) its working good. when i hosted this project in to my server(PHP 7.1) using cpanel after login its return 419 Page Expired Error.

Mylogin Form Code :

<form method="POST" action="{{ route('login') }}" id="login-form">
    @csrf
    <div class="form-group">
      <label for="username">{{ __('Username / Email Address') }}</label>
      <input type="text" class="form-control{{ $errors->has('username') ? ' is-invalid' : '' }} boxed" name="username" id="username" value="{{ old('username') }}" required autofocus>
    </div>
    @if ($errors->has('email'))
       <span class="invalid-feedback" role="alert">
          <strong>{{ $errors->first('email') }}</strong>
       </span>
    @endif

    <div class="form-group">
        <label for="password">{{ __('Password') }}</label>
        <input type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }} boxed" name="password" id="password" required>
    </div>
    @if ($errors->has('password'))
        <span class="invalid-feedback" role="alert">
           <strong>{{ $errors->first('password') }}</strong>
        </span>
    @endif

    <div class="form-group" style="margin-bottom: 0px; float:left;">
        @if (Route::has('password.request'))
            <a href="{{ route('password.request') }}" class="forgetpwd">
               {{ __('Forgot Your Password?') }}
            </a>
        @endif
    </div>

    <div class="form-group" style="text-align: center;">

        <button type="submit" class="btn btn-warning" style="padding:0.5rem 1.8rem;">Login</button>
    </div>
</form>

I cleared Cache and Cookies but, Same issue Displayed.

Answer

farooq picture farooq · Sep 3, 2019

Use this in the head section instead of @csrf :

<meta name="csrf-token" content="{{ csrf_token() }}">