gpt4 book ai didi

javascript - JQuery - 从响应中获取 Cookie

转载 作者:行者123 更新时间:2023-12-01 01:47:04 24 4
gpt4 key购买 nike

我已经向服务器发送了一个 POST 请求,响应中有一个我需要存储的 cookie

$.ajax({
type: "POST",
url: url + "api/Login",
headers: { "Authorization": headerData },
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: "text"
}).then(
function (data, textStatus, jqXHR) {
// get the current default Breeze AJAX adapter
var ajaxAdapter = breeze.config.getAdapterInstance("ajax");

var cookies = document.cookie ? document.cookie.split('; ') : [];

for (var i = 0, l = cookies.length; i < l; i++) {
console.log(cookies[i]);
}
console.log('Cookie');

ajaxAdapter.defaultSettings = {
headers: {
// any headers that you want to specify.
"Cookie": jqXHR.getResponseHeader('Set-Cookie')
},
};

但我无法撤销 cookie,我还可以使用哪些其他工具?

这是服务器响应

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Server: Microsoft-IIS/7.5
Set-Cookie: session-token=227c268d-dae5-4c54-a05a-90f2401592d3; domain=172.18.25.168; path=/
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 10 Dec 2013 20:47:07 GMT
Content-Length: 0

最佳答案

为什么不直接在服务器端文件上回显/打印 cookie,然后使用(数据)处理它?<​​/p>

关于javascript - JQuery - 从响应中获取 Cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20504807/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com