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?
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
In blade, you can use
{{csrf_token()}}
to quickly get the csrf token valueTrack 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
1. Obtain through Session facade
2. Use app to create a session instance to obtain
3. Get it from blade