Summer Sale! All accounts are 50% off this week.

NomaD's avatar

Tokenmismatchexception

Hello, recently i updated 2 files in production and some clients complained they couldn't send appointments (form submitted vie ajax to server). i checked it by myself , filled out form and it was submitted successfully while client keep complaining, so i checked storage/logs and saw to many tokenmissmatchexception. after i had to comment \App\Http\Middleware\VerifyCsrfToken::class in kernel.php in order to stop this. anyone can tall why it happened , some clients could send appointment including me and some of them can't

0 likes
4 replies
NomaD's avatar

For more information i am using view caching in local storage

SaeedPrez's avatar

Are they refreshing the page or just hitting back button and trying to re-submit?

You could implement something like this to refresh the token if they leave the page open long periods of time.

1 like
NomaD's avatar

i cant tell exact case for clients , that is the problem.

NomaD's avatar
NomaD
OP
Best Answer
Level 2

The problem was that i was caching views, so client had old token generated while server refreshed it. solution was that i send request from client to refresh token once when page loads.

Please or to participate in this conversation.