Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

6ber6ou's avatar

Handle TokenMismatchException

Hi all.

To handle TokenMismatchException I use this code (app/Exceptions/Handler.php) :

public function render( $request, Exception $exception )
    {

    if( $exception instanceof \Illuminate\Session\TokenMismatchException )
        {

        return redirect( $request->route( 'login' ) );

        }

    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    return parent::render( $request, $exception );

    }

But his doesn't works, could you explain me why

0 likes
1 reply
6ber6ou's avatar
6ber6ou
OP
Best Answer
Level 3

Ok I found my error :

return redirect()->route( 'login' );

Please or to participate in this conversation.