What is the best way to handle expired login forms (expired tokens)
If someone logs out and leaves their form open overnight and come back the following day and login they get an error due to the expired token.
I would like to handle this error and send them back to the login screen with a message that for security reasons their form had been inactive too long please login.
Using Laravel 5, looks like this should be setup in the Handler.php
I gave this a try but it doesn't seem to be catching the error:
if($e instanceof TokenMismatchException) { return redirect('login')->with('message', 'Your form had expired for security reasons. To prevent this refresh the login page prior to logging in.'); }
Should you be always redirecting to the login page regardless of where the tokenmismatch happened? Maybe they were already logged in but it happened on another form.
Where did you put that code in Handler.php? Remember to wrap it into code blocks on the forums with 3x ` or ~ at the start and end.