Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> XMLHttpRequest always sends browser cookies

No:

The XMLHttpRequest.withCredentials property is a boolean value that indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies, authorization headers or TLS client certificates.

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequ...



The blog post seems to only be referring to same-site requests for XHR, whereas your response is only referring to cross-site requests. A more complete correction would be:

XMLHttpRequest always sends browser cookies for same-origin requests. They are not included for cross-origin requests unless explicitly requested. Fetch does not send cookies by default for either type of request, unless explicitly requested.

Also note that the server must use the Access-Control-Allow-Credentials header for the response to be made available to the client code when making a cross-origin request with credentials.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Ac...


Even more important: it's value is `false` by default.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: