HTML5下经过response header解决跨域AJAX cookie的问题

ajax:javascript

经过给Response Header添加Access-Control-Allow-Origin:*  来解决跨域请求,*表明容许全部的跨域请求,或者把*换成指定的域名java

 

cookie:jquery

服务端须要在Response Header中加入头ajax

Access-Control-Allow-Credentials:true 跨域

而后客户端的ajax的withCredentials属性设置为True。  jquery中设置以下:浏览器

$.ajax({
url:"B.abc.com",
xhrFields:{
withCredentials:true
},
crossDomain:true
});

 

以上方式必须在IE11或以上浏览器上才能支持cookie

相关文章
相关标签/搜索