This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

withCredentials

Summary

Returns or sets whether cross-site Access-Control requests should be made using credentials such as cookies or authorization headers.

Property of apis/xhr/XMLHttpRequestapis/xhr/XMLHttpRequest

Syntax

var result = element.withCredentials;
element.withCredentials = value;

Return Value

Returns an object of type BooleanBoolean

Default is false.

Examples

var xhr = new XMLHttpRequest();
xhr.open("GET", "http://updates.html5rocks.com", true);
xhr.withCredentials = true;
xhr.send();

Notes

withCredentials cannot be set after the XMLHttpRequest’s send() method is called.

Related specifications

W3C XMLHttpRequest Specification
W3C Working Draft
Cross-Origin Resource Sharing
W3C Candidate Recommendation 29 January 2013

Attributions