Laravel enables csrf by default, using csrf_token() to generate a random string and save it in the browser and session file. Then find the corresponding session file based on the cookie returned by the browser, and obtain the token for comparison.
But the problem is that if you use load balancing and configure several servers, you cannot obtain the token for verification through the session file saved on the server. Multiple servers correspond to one website. How to use laravel's csrf defense? Is it possible to set it up? Session file sharing to solve this problem? If so, how to set it up on nginx?
The session is stored in the database and can be shared after being stored in the database
This has nothing to do with nginx, what you need is to modify the Session Driver