Answer the question
In order to leave comments, you need to log in
How to update csrf-token in laravel?
All POST requests in laravel are filtered by csrf-token. After some time, the token expires and the user cannot send requests. And if it is a SPA, then the user may not refresh the page for a very long time. On stackoverflow, it is advised to write a script that will receive a new token via Ajax and run it via setInterval.
Please explain, as I understand it, the token is given for a certain time. Let's say for half an hour and during this half hour it does not change. That is, if the user logged in at 13:00, then the token will be valid until 13:30. If so, then setInterval must work very accurately, otherwise it won't update it. For example, if he requests a new one at 13:29:59, he will receive the old one.
How to use csrf protection in this case?
Answer the question
In order to leave comments, you need to log in
With each request to the token, the cookie time is updated.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question