Support the ongoing development of Laravel.io →
Views Forms Installation
Last updated 2 years ago.
0
Solution

I solved this actually.:

I put:

<input type="hidden" id="csrf_token" value="{{ csrf_token() }}"/>

in the view where the form is rendered.
Then I pulled out the value in js :

csrf_token = document.getElementById('csrf_token');

and put it in the form like this:

<input type="hidden" name="_token" value="'+csrf_token.value+'">\
Last updated 7 years ago.
0

How about sending it as a cookie? And then use a filter to check this cookie? If you mark your cookie as HTTP secure, then all request will send this. And you don't need to JavaScript worry about it.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

seki98 seki98 Joined 23 Aug 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.