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

@laravelcode did you ever find a solution to this?

0

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);
	}
}
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.