0

Whenever i try to login i get this error: Page Expired the page has expired due to inactivity. I have been working on this project and suddenly i get this error but i don't know how. This did not happen before. I use laravel's default view templates and Auth::routes();

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Login') }}</div>

                <div class="card-body">
                    <form method="POST" action="{{ route('login') }}" aria-label="{{ __('Login') }}">
                        @csrf

                        <div class="form-group row">
                            <label for="email" class="col-sm-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>

                                @if ($errors->has('email'))
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>

                                @if ($errors->has('password'))
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $errors->first('password') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group row">
                            <div class="col-md-6 offset-md-4">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>

                                    <label class="form-check-label" for="remember">
                                        {{ __('Remember Me') }}
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group row mb-0">
                            <div class="col-md-8 offset-md-4">
                                <button type="submit" class="btn btn-primary">
                                    {{ __('Login') }}
                                </button>

                                <a class="btn btn-link" href="{{ route('password.request') }}">
                                    {{ __('Forgot Your Password?') }}
                                </a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

What i have tried:

Check if i have csrf token included in login page.

composer dump-autoload

php artisan optimize
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
Remove browser cache

This is the login view

I took a look at this post: "The page has expired due to inactivity" - Laravel 5.5

And did not help.

My application is live on server and uses same code as on my local machine. On server everything works perfectly find.

Miljan Rakita
  • 1,323
  • 4
  • 20
  • 42
  • 1
    Can you show the form you use on the login page so we can verify that you have used the CSRF token properly? – Luke Ramsden Sep 19 '18 at 13:05
  • @LukeRamsden i have edited my question. – Miljan Rakita Sep 19 '18 at 13:09
  • @LukeRamsden I havent changed the form since day one. And i have been working on this project over a month now, so i don't think it is problem in form. – Miljan Rakita Sep 19 '18 at 13:09
  • Have you tried what syam answered with? – Luke Ramsden Sep 19 '18 at 13:10
  • @LukeRamsden yes i did, did not help – Miljan Rakita Sep 19 '18 at 13:10
  • @MiljanRakita, are you sure you looked at everything in the duplicate? This is almost always a session error. – Devon Sep 19 '18 at 13:21
  • @Devon i just checked, it seems like my env() is not working. It always returns null or default value. – Miljan Rakita Sep 19 '18 at 13:41
  • @MiljanRakita That's caused by config caching – Devon Sep 19 '18 at 14:17
  • @Devon i have fixed env. But problem is still the same, i have tried everything already. Any other idea ? – Miljan Rakita Sep 19 '18 at 14:39
  • Did you verify your session config file like I suggested in my answer? – Devon Sep 19 '18 at 14:42
  • @Devon yes i did, still no luck. Error keeps coming – Miljan Rakita Sep 19 '18 at 15:43
  • @Devon i did everything what they suggested and still does not work. When i try to login i get Page expired error. When i take a look at request post body i send there is email,password and token. _token: EbOljb7nXaCdstA7LLBUoI7ph9qJf97rV5bt2oAe So i know i send csrf for sure. But it does not exist in database in users table. So it is not inserted, any idea what could cause that problem ? – Miljan Rakita Sep 19 '18 at 22:44
  • I know what can cause the problem, the session data isn't being persisted, the same issue covered in the duplicate, but there are various causes, you'll have to debug further if none of those answers are helping. – Devon Sep 19 '18 at 23:25

0 Answers0