Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: error "The page has expired due to inactivity" (419 unknown status)

I get the error The page has expired due to inactivity. Please refresh and try again. on a Laravel 5.6.39. In Chrome "Network tab" says error login - 419 unknown status

As soon as I refresh the page, I immediately get the error. So I never see the login view anymore, then I'm stuck. Think to common users that have no experience and only try to refresh the page. If it doesn't work they leave your app.

I can reproduce the error following these steps:

  • go to login view
  • enter username and password and don't check "remember me" flag
  • wait that session expires (for test purpose I set SESSION_LIFETIME to 1 minute)
  • hit Login button and I get that error

I already read and tried the most common causes:

  • @csrf is present in the login form (it's the default authentication by Laravel)
  • the folder storage has 755 but tried also with 775 and 777
  • tried to launch php artisan cache:clear php artisan config:clear php artisan route:clear php artisan view:clear php artisan config:cache php artisan key:generate
  • I'm using the default SESSION_DRIVER=file but in production I also tried to replace it with SESSION_DRIVER=cookie with SESSION_DOMAIN=https://app.my-domain.com/

Here you'll find my code (controllers, view, routes, .env, ...): https://gist.github.com/dangelion/aa7fc54ea75f7b2d6062fc79f07e04e8

I really have no more idea to solve this. Some helps? Thanks

like image 667
Fred K Avatar asked Nov 16 '22 16:11

Fred K


1 Answers

When we update our application, a browser may still use old files. If you don’t clear your cache, Old files can access problems when you apply.

after add @csrf in form Clear the browser cache and now hope this might work

like image 181
Udhav Sarvaiya Avatar answered Nov 19 '22 09:11

Udhav Sarvaiya