Support the ongoing development of →
Authentication Security Session
Last updated 1 year ago.

@laravelcode did you ever find a solution to this?


I don't know what was wrong with @laravelcode's code, but he got the right idea--add the check for TokenMismatchException to render method of App\Exception\Handler class, as per documentation.

Here's mine (irrelevant parts skipped):

<?php namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Session\TokenMismatchException;

class Handler extends ExceptionHandler {
	public function render($request, Exception $e)
		if ($e instanceof TokenMismatchException) {
			return redirect()->back()->with('message', 'Security token expired. Please, repeat your request.');
		return parent::render($request, $e);

Sign in to participate in this thread!

Full Stack Europe

Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.