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

welcomattic's avatar

TokenMismatchException after upgrading to 5.1

Hi!

I just upgraded my app from 5.0 to 5.1.11, I followed the upgrade guide, and I caught this error when I want to logged me in :

TokenMismatchException in VerifyCsrfToken.php line 53

In my form, there is this :

<form class="form-horizontal" role="form" method="POST" action="/auth/login">
    {!! csrf_field() !!}
[...]

I'm lost, I don't understand why this error throw.

Thanks for helping!

0 likes
2 replies
Bloomanity's avatar

Check Illuminate\Foundation\Http\Middleware\VerifyCsrfToken@tokensMatch and

var_dump($request->session()->token());
dd($token);

see if they match

1 like
welcomattic's avatar

Hi!

They don't match:

string 'NGjxavJcHuIdTzFxdraCSrKeoSL956do7xSbypgD' (length=40)
"s8nir6eDLURLX1rlyDlHOOOdadRt54Q6MRoWRNmF"

Do you have any idea why they don't match?

Please or to participate in this conversation.