Ad

Page Expired Exception In Laravel?

- 1 answer

This is often seen in Laravel. When a form is submitted, sometimes the application redirects to a page saying:

The page has expired due to inactivity.

Please refresh and try again.

I know that this is a security mechanism in Laravel against CSRF. How can it be prevented from displaying since this may not be appropriate when application is deployed in production server.

Ad

Answer

It's the 419.blade.php template that is being resolved.

If you want to change the message, you can make this file in views/errors/419.blade.php

If you want to capture the exception and perform your own actions against it, you can use the App\Exceptions\Handler.php and specifically capture $e instanceof TokenMismatchException.

Then within that conditional you can choose what action to take.

Ad
source: stackoverflow.com
Ad