A developer encountered an issue where HTTPOnly cookies were not being set in the browser while developing a REST API locally.
Various approaches were employed to troubleshoot the issue, including:
Despite following recommended practices, the HTTPOnly cookie property remained unset in both cases. The problem was eventually traced to the JavaScript fetch() method used in the front-end.
The problem was resolved by adding the credentials: 'include' option to the fetch() request. This allows the browser to send and receive cookies, enabling the HTTPOnly attribute to function as intended.
The above is the detailed content of Why Aren\'t My HTTPOnly Cookies Setting on Localhost Using `fetch()`?. For more information, please follow other related articles on the PHP Chinese website!