跨域 cookies

script标签请求的js脚本,如果跨域了,请求会带有外域的cookies信息。

XMLHttpRequest请求跨域时,需要有Access-Control-*等的头信息,如果需要将cookies传输到外域,需要增加

xhr.withCredentials = true; //支持跨域发送cookies  

jquery的ajax,增加

crossDomain: true

xhrFields: {

    withCredentials: true

 }

选项

此外服务端也要有些修改

header("Access-Control-Allow-Credentials: true");
原文地址:https://www.cnblogs.com/mahuan2/p/7567787.html