This article might get you started.
https://hisman.co/article/laravel-csrf-token-mistmatch-exception/
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a number of pages where a logged-in user submits form information.
Obviously these forms use @csrf as required.
However if the user takes a long time to enter the information (or if they open another tab and logout in that other tab) then when they submit the form they get a 419 error.
However what I would like to do is to catch the error, save the form data they entered and then show them a login form.
If they then successfully login I want to carry on with the saved form data as if their session had not timed out in the first place.
Is this possible and if so how?
Thanks,
Martin
=====================================
By way of illustration, I would like my code to say something like:
if ( !logged_in() ) return view ('login-form', ["request_for_field_data_to_save" => $request]; // Process form data in $request
and obviously each page would have a separate 'login-form' view that knew what fields to preserve
Please or to participate in this conversation.