我正在尝试使用 XMLHttpRequest 在 XSS 请求中设置 Cookie。
我找到了XMLHttpRequest Specification,第 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;
}
});