Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a CORS request in IE9 with cookies?

In IE9, I am attempting to make a cross origin request with cookies. However, even when I have the Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Access-Control-Allow-Methods all set to the appropriate values (the origin domain, true, and GET, POST), IE9 still isn't sending or setting cookies from the request. Here's the script I'm using:

var xdr = new XDomainRequest()
xdr.open("http://mydomain.com/cors.php")
xdr.withCredentials = true;
xdr.send();

Any idea on how to get cookies to work with CORS requests in IE9?

like image 904
Jeff Avatar asked Jun 07 '12 23:06

Jeff


People also ask

How do I send a cookie with CORS request?

To allow receiving & sending cookies by a CORS request successfully, do the following. Back-end (server) HTTP header settings: Set the HTTP header Access-Control-Allow-Credentials value to true . Make sure the HTTP headers Access-Control-Allow-Origin and Access-Control-Allow-Headers are set and not with a wildcard * .

How to allow CORS in browser?

Simply activate the add-on and perform the request. CORS or Cross-Origin Resource Sharing is blocked in modern browsers by default (in JavaScript APIs). Installing this add-on will allow you to unblock this feature.

Are cookies sent cross-origin?

By default, Cookies are neither set nor sent in CORS Requests.


1 Answers

From this page http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx at the bottom you can see Update: Internet Explorer 10 now supports CORS using XMLHTTPRequest. It means CORS is not handled properly in IE9. Sorry. They propose some workarounds with proxy in the same article.

Browser compatibility matrix is given at http://caniuse.com/cors where by partial support they mean

Internet Explorer 8 provides support via the XDomainRequest object but doesn't support credentialed requests http://code.google.com/p/sgvizler/wiki/Compatibility.

like image 136
Artem Oboturov Avatar answered Oct 17 '22 08:10

Artem Oboturov