Closed carlosvaldesweb closed 1 year ago
Thanks
The reason it is necessary to sometimes make a csrf request after logging in is because the csrf cookie set by Laravel has an expiration date configured by Laravel's session lifetime (120 minutes by default). So if a user logged in, checked the "remember me" option, then closed his browser and returned after 2 hours, he is still logged in but the csrf token has expired by then.
Hello, i'm looking that initCsrf function is called always, so if i make a post request e.g to /blogs, always first is called /sanctum/csrf-cookie. I think that CSRF route only should be called in login and register but i could be wrong. I want to develop a module where the user can save while he writes with a short debounce, so the user can make many requests while he is tipyng, i wouldn't like that if the user make 50 requests they be 100 by always make initCsrf. According laravel docs:
Laravel CSRF Docs
Sanctum docs
If we have e.g. forms or routes that we need to be protected if we are guest users, maybe we can use like this, to not use only in login and register: