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

adelgado116's avatar

TokenMismatchException in VerifyCsrfToken.php line 67:

Hi everyone, The error happens when trying to update records with a form. I followed the Laravel from Scratch series, don't think there are errors on my code. As per other posts, it seems there are important changes between Laravel 5.2 (which I am using) and 5.0 (the one used at the time the series was recorded). Is downgrading to 5.0 version a good solution to this problem? if not, please help on how to adapt the project to Laravel 5.2. Thanks!

0 likes
6 replies
Snapey's avatar

You haven't said that you are including a csrf token in your form?

ie, {{ csrf_field() }}

adelgado116's avatar

@Snapey, Thanks for your prompt reply! After reading about that point, I included the csrf token within the form and also as part of the meta tag:

on the Form: {{ method_field('PATCH') }} {{ csrf_token() }}

On layout file, inside the meta tag: name="csrf-token" content="{{ csrf_token() }}"

problem persists.

toniperic's avatar

@adelgado116 can you open the form, check the token's value, refresh the page and check whether token's value has changed?

Sounds like session's being re-created on every page request.

Snapey's avatar

No, not csrf_token(), should be csrf_field()

Token is just the token. csrf_field() is a full hidden form element named token. You don't need it in the meta element unless you plan to use ajax and want to grab it client side from the meta field.

adelgado116's avatar

confirming here: Adding the routes to a "web" middleware AND adding the {{ csrf_field() }} in to the form will work. No more "TokenMismatchException in VerifyCsrfToken.php line 67:" @Snapey, @toniperic - Thanks!

Please or to participate in this conversation.