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

Rmpalija's avatar

CSRF token and bootstrap model

Hello, I create one button and bootstrap model to popup.. in my model i have my login form. And when user try to login, i get error

TokenMismatchException in VerifyCsrfToken.php line 53:

I found out that this will work if i disable my csrf token... in Kernel.php. Also i try to add token in meta tags and then add jqery script, but again i have the same error. Do you maybe have any idea, how to avoid this ?

0 likes
5 replies
bashy's avatar

Using AJAX or just normal form POST?

bashy's avatar

Then if you use LaravelCollective Form helper, it will auto generate the CSRF token in the form.

You can also use csrf_field() to generate it in your form.

splaq's avatar
splaq
Best Answer
Level 4

I've found that you have to include {!! csrf_field() !!} following <form action="" method=""... otherwise it doesn't work.. so you would have this..

<form action="/your/action" method="POST">
    {!! csrf_field() !!} 
    ...
1 like

Please or to participate in this conversation.