I have been suffering this TokenMismatchException. So I was figuring what causes the error. I found out that If I try to idle the landing page for 15minutes then login. I got the TokenMismatchException. I have a {!! csrf_field() !!} in the loginform.
My config/session.php lifetime is set to 15 minutes. So I've waited 15minutes to catch the TokenMismatchException error.
So I have tried these several solutions
- installed laravel-caffeine
<meta name="csrf-token" content="{{ csrf_token() }}" />
Edited the Handler.php
public function render($request, Exception $e) { if ($e instanceof TokenMismatchException) { return redirect('/login')->with('message', 'Security token expired. Please, login back.'); } if ($e instanceof \Illuminate\Session\TokenMismatchException) { return redirect('/login')->with('message', 'Security token expired. Please, login back.'); } return parent::render($request, $e); }
But nothing seems working.