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

reidaigo's avatar

Session token doesn't equals form token

When page's loaded, session token is "aaa", form token is "aaa" (for example). When form submits, form token stays "aaa", but session token becomes "bbb". So it calls TokenMismatchException. I checked it by

echo  $request->session()->token() . "!=" . $request->input('_token') ?: $request->header('X-CSRF-TOKEN');

More info: in browser i'm looking for such cookies as "laravel_session" and "XSRF_token", but they didn't exist in my app. Cookies storage is empty.

I get this problems only in local machine. Not locally All works fine.

Also when page reloads, a new session file is created.

Session and cache options in ENV file: CACHE_DRIVER=file SESSION_DRIVER=file

0 likes
0 replies

Please or to participate in this conversation.