HTTPOnly Cookie Not Setting in Browser on Localhost
Problem:
In a REST API with a login endpoint that generates an HTTPOnly cookie, the cookie was no longer being set in the browser, even though POST requests via Postman worked correctly. This issue occurred despite using approaches that had previously functioned.
Approaches Used:
Results:
Solution:
The problem was in the client-side JavaScript (fetch() method). By adding the 'credentials: "include"' option to the RequestInit object, the browser was allowed to send and receive cookies with the request. This is necessary for HTTPOnly cookies to be set in the browser.
Additional Information:
The above is the detailed content of Why Aren\'t My HTTPOnly Cookies Setting in the Browser on Localhost?. For more information, please follow other related articles on the PHP Chinese website!