The perfect solution for Ajax cross-origin request cookies is: ajaxcookie
1. Native ajax request method:
1 var xhr = new XMLHttpRequest ();
2 xhr. open ("POST", "http://xxxx.com/demo/ B /index.php", true );
3 xhr. withCredentials = true; // supports sending cookies across domains.
4 xhr. send ();
2. jquery's ajax post method request:
$. Ajax ({type: "POST", url: "http://xxx.com/api/test", dataType: 'json', // allowed to carry the certificate xhrFields: {withCredentials: true}, // allowed cross-domain crossDomain: true, success: function () {}, error: function (){}})
3. server settings:
Header ("Access-Control-Allow-Credentials: true"); header ("Access-Control-Allow-Origin: http://www.xxx.com ");
The above is a perfect solution for the failure to bring Ajax cross-origin request cookies introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!