Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

wickedsp1d3r's avatar

TokenMismatchException

Today I encountered the following error, and I am not able to resolve it. The error occures when trying to submit a simple login form. Does someone have any idea, where can I begin to look for a solution?

TokenMismatchException in VerifyCsrfToken.php line 46:
in VerifyCsrfToken.php line 46
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Stack.php line 96
at Stack->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Stack.php line 96
at Stack->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 52
at StartSession->handle(object(Request), object(Closure)) in Stack.php line 96
at Stack->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Stack.php line 96
at Stack->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Stack.php line 96
at Stack->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Stack.php line 96
at Stack->Illuminate\Routing\{closure}(object(Request)) in Language.php line 40
at Language->handle(object(Request), object(Closure)) in Stack.php line 96
at Stack->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Stack.php line 82
at Stack->then(object(Closure)) in Kernel.php line 107
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 82
at Kernel->handle(object(Request)) in index.php line 53
0 likes
12 replies
bashy's avatar

Did the form data include the _token field?

You can check in your browser in the network tab via developer tools

bashy's avatar

Then it must differ from the session value of the token. Check to see if you reinitialise the session (therefore getting a new token).

Does the token change on each load or can you compare it in the session itself?

jimmy.puckett's avatar

We see that error from time to time when people sit on the login screen for too long before submitting the creds. The session expires out & even though the token was valid, it expires by the time they submit.

2 likes
DutGRIFF's avatar

I was getting this message because my disk was out of space. df -H pointed this out but not until a lot of other debugging.

When the disk is full laravel can't save the updated csrf token but return it to the browser where it is then used. This kinda seems like a bug. Shouldn't it respond with an error instead of the token it can't save?

madandhakal's avatar

In local server it is working good but in sever this Tokenmismatch problem comes.. how to solve this problem .. i am new in laravel 5

imam's avatar

insert input tag in your form with type="hidden" , name="_token" and value="csrf_token()"

because your form not send csrf_token

Please or to participate in this conversation.