How To Solve The Page Expired 419 Error In Laravel

WebSolutionStuff | Jun-28-2020 | Categories : Laravel

In this article, we will see how to fix 419 page expired in laravel. Many times we faced “The page has expired due to inactivity. Please refresh and try again”. error in laravel. This problem is caused by the csrf_token. So, below I have added two solutions to this error check and applied them as per your requirements.

So, let's see how to solve 419 errors in laravel and  419 page expired laravel ajax.

Solution 1:

If you are getting an error after submitting the form in laravel then you need to add the CSRF field in your form like below.

<form method="POST" action="/test">



Solution 2:

 If you are getting an error after an AJAX call then you need to add a header like the below in the meta tag.

In your head tag add the below line code.

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

And after that, you need to add below code in your script tag.

    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

In some conditions also happen Cache issue, So, we need to clear it.

For clearing Cache, View, and Routes in Laravel check below.


You might also like:

Recommended Post

Featured Post

Follow us
facebooklogo github instagram twitter