Excuse me, masters, how can I use csrf_token in Laravel without a view? I wrote a php file in public, and wrote a form in it that needs to be submitted by post, but csrf_token cannot be used. How to solve this problem?
巴扎黑2017-05-16 16:52:07
In blade, you can use {{csrf_token()}}
to quickly get the csrf token value
Track into the source code: app('session')->getToken()
.
From the above code, it should be inconvenient to use, because your own php file under public does not start laravel core resources through index.php, and the session must not be obtained. Laravel's session is processed and is not PHP native session
滿天的星座2017-05-16 16:52:07
Session::token();
app('session')->getToken();
{{csrf_token()}}