Search code examples
laravellaravel-5laravel-session

why error "laravel 5.5 The page has expired due to inactivity. Please refresh and try again" even after {{ csrf_field() }}


I already have {{ csrf_field() }} in form. it works fine but after inactivity for some time create this error. why ?


Solution

  • You should change lifetime of your session so that CSRF token could stick around longer. It is set up in config/session.php file, by default it's configured as:

    'lifetime' => env('SESSION_LIFETIME', 120),
    

    Meaning your session will persist for 120 minutes by default if not set otherwise in your .env file.