Answer the question
In order to leave comments, you need to log in
Laravel: _token value disappears after form submission. How to fix?
Good afternoon, dear developers. I would never post a question. Especially since he seems stupid to me. But I have already rummaged through the entire Toaster and the entire Internet.
Framework - laravel
The situation is as follows:
1. There is a form at post/add . It generates a hidden _token (using the Form:: facade or using the csrf_field() function - it doesn't matter) It looks like this:
<input name="_token" type="hidden" value="здесь токен">
return redirect('post/add');
<input name="_token" type="hidden">
Answer the question
In order to leave comments, you need to log in
Yeah, the following was discovered by typing:
before making a redirect in the handler
There is such a code:
So, if you comment it out, then everything starts working. It turns out that this function somehow overlaps the token?
Can't delete my own question because I answered it myself.
The issue has been resolved. Apparently, working 18 hours in a row is harmful. Need to go to sleep. It turned out that there was a "flush" of all the values before the form was displayed, so the token was not displayed.
Removed this piece of code and it all worked!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question