1
我需要用户的sessionid进行服务器端身份验证。因此,需要在每个请求的头部中发布Sessionid,而这些都是必不可少的。我正在使用以下在标题中发布sessionId,但发生了错误。发生将sessionid添加为POST请求使用ajax请求与framework7请求
apiservice.getProfileDetails = function(data, callback){
// $.cookie("sessionid", $.jStorage.get("sessionKey"));
document.cookie = "sessionid=" +$.jStorage.get("sessionKey");
console.log(document.cookie);
var requestEnvelope = {
url: apiservice.baseUrl + '/get/my/information/?callback='+callback,
xhrFields: {withCredentials: true},
crossDomain: true,
async: false,
type: 'POST',
// beforeSend : function(xhr) { var cookie = credentials["COOKIE"]; console.info("adding cookie: "+ $.jStorage.get("sessionKey")); xhr.setRequestHeader('Cookie', $.jStorage.get("sessionKey")); },
beforeSend: function (request)
{
request.setRequestHeader("Cookie", "sessionid=" +$.jStorage.get("sessionKey"));
},
// setCookies: $.jStorage.get("sessionKey"),
// headers: {"sessionid": $.jStorage.get("sessionKey")},
data: JSON.stringify(data),
complete: function(res){
ux.getProfileDetails(res.responseText);
}
}
$.ajax(requestEnvelope);
};
错误是jquery.min.js:4 Refused to set unsafe header "Cookie"
也试过来设置cookies在头
headers: {"sessionid": $.jStorage.get("sessionKey")},
,但同样的错误,任何解决方案