Level 13
Did you forget to use \Illuminate\Session\TokenMismatchException;?
Alternatively,
if($e instanceof \Illuminate\Session\TokenMismatchException)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I do not know whether this is a good practice. I am trying to redirect the user to the login page after token mismatch.
public function render($request, Exception $exception)
{
if ($e instanceof TokenMismatchException ) {
return redirect()->route('login');
}
return parent::render($request, $e);
But, it is still not working. I get a blank page. How do I redirect to login from here and is it Ok?
Thank you
Can you add a dd() to check if you're hitting the condition?
public function render($request, Exception $exception)
{
if ($e instanceof TokenMismatchException ) {
dd($e);
return redirect()->route('login');
}
return parent::render($request, $e);
}
Please or to participate in this conversation.