Answer the question
In order to leave comments, you need to log in
How to properly handle the ErrorException in VerifyCsrfToken error that appears if the form is open for a long time?
There is csrf_token() in the head, there is csrf_field() in the form, everything is ok, everything works.
The error occurs if you leave the form open for a while and then submit.
If I understand correctly, the error occurs because the token (header in the XSRF-TOKEN cookie) has already expired (its lifetime is 2h).
Where and how to process it correctly?
Answer the question
In order to leave comments, you need to log in
1) Well, for example, open App/Http/Middleware/VerifyCsrfToken.php and inherit handle.
public function handle($request, Closure $next)
{
try {
return parent::handle($request, $next);
} catch (TokenMismatchException $exception) {
// ...
}
}
if ($exception instanceof TokenMismatchException)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question