我正在尝试使用XMLHttpRequest在XSS请求中设置Cookie。
我发现XMLHttpRequest规范,其中4.6.2-5部分似乎暗示不允许设置Cookie、Cookie2和一些其他标头,但我希望有一种解决方法。
下面是我的(jQuery)代码,但由于Cookie没有被设置,所以查询失败了。
$.ajax( {
type : "POST",
url : URL,
data: SOAP_INBOX_MAIL_QUERY,
dataType : "xml",
async: false,
beforeSend : function(xhr) {
var cookie = credentials["COOKIE"];
console.info( "adding cookie: "+ cookie );
xhr.setRequestHeader('Cookie', cookie);
},
success : function(data, textStatus, xmLHttpRequest){
},
error : function(xhr, ajaxOptions, thrownError) {
credentials = null;
}
});