withCredentials
withCredentials is a boolean property of the XMLHttpRequest (XHR) object that controls whether cross-origin requests should be made with credentials. Credentials can include cookies, authorization headers, and TLS client certificates. The property does not affect same-origin requests in most environments; it mainly governs cross-origin behavior. By default, withCredentials is false, meaning cross-origin requests do not include credentials unless explicitly enabled.
When withCredentials is set to true, the browser will include cookies and other credentials in cross-origin
On the server side, enabling credentials requires corresponding CORS (Cross-Origin Resource Sharing) support. The server must
Related behavior includes the handling of preflight requests. Cross-origin requests that include credentials may trigger an
In modern web APIs, the Fetch API provides a similar capability via a credentials option (for example,