[英]Read cookies sent by server when using POST request for login
我正在执行POST登录请求,登录服务器后会发送标头“ Set-Cookie”,但必须将其放入浏览器中。我尝试了所有这些方法都没有用
$.ajax(settings).done(function (data, status, headers, config) {
console.log(data);
//$cookies['Set-Cookie']=response.headers('Set-Cookie');
//console.log(headers);
//console.log(headears()['Set-Cookie']);
//console.log(headears(['Set-Cookie']));
console.log(headers.getResponseHeaders()['Set-Cookie']);
});
console.log(headers);
在控制台上打印“成功”,对于其他人,我得到“未定义”或“标头不是函数”。有人可以帮帮我。我尝试了在论坛上看到的所有方法都没有用。谢谢。
我最近console.log( $cookies.get('xxx'));
使用此console.log( $cookies.get('xxx'));
但是问题是$cookies.get()
仅在cookie已经存储在浏览器中时才起作用。我想从printscreent的标题中获取它们并使用$cookies.put('myfav','oo');
谢谢。 响应标题
您需要阅读Set-Cookie
创建的实际cookie。
尝试
console.log( $cookies.get('CookieName'));
另请注意,如果它是httpOnly
cookie,则您将无法访问它。 跨域请求也是如此
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.