Hopefully this is simple to answer.
With a credentialed request in XHR2, which cookies are sent?
I've been following the MDN article on credentialed requests, and it shows that the cookie pageAccess=2
is sent with the request. However it doesn't explain where that cookie comes from, and why that cookie specifically is being sent. Is it simply that all cookies set by the page are sent in any credentialed request?
From the HTML5 Rocks page on CORS:
I assume "any cookies" means "all cookies" (probably subject to a HTTPS-only flag on the cookie), since there is no mechanism to specify cookies with XHR2.
The cookies that get sent are the cookies that were set by the remote domain: if
foo.com
sends a request a credentialed request tobar.com
, any cookies set bybar.com
are sent. To put this in practical terms, supposefacebook.com
has a CORS-aware API that requires you to be logged in to use. I've logged in to Facebook earlier in my browser session, but now I'm browsingfoo.com
, which is going to use Facebook's API on my behalf.foo.com
asks th ebrowser to send a cross-domain request tofacebook.com
along with all myfacebook.com
cookies so Facebook knows who I am and that I've already authenticated to Facebook.