![](/img/trans.png)
[英]Is it possible to get the Set-Cookie value from an HTTP response header in JavaScript?
[英]Get set-cookie value from the response header angular
我正在尝试从Response Headers
获取set-cookie
。
这样做的原因是 set-cookie 没有设置 cookie 并显示警告This attempt to set a cookie via a Set-Cookie header was blocked because its Domain attribute was invalid with regards to the current host url
. 附上截图
现在我想通过以下代码从 Response Header 中获取 set-cookie 值
但它总是为set-cookie
返回null
但返回值 fo expires
。
请任何人指导如何解决此问题或如何从响应 Header 中获取set-cookie
的值。
任何帮助将不胜感激。
谢谢
根据developer.mozilla.org set-cookie
是禁止响应 header 名称。 您无法使用浏览器端 JavaScript 读取它
根据 Fetch 规范的要求,浏览器阻止前端 JavaScript 代码访问 Set Cookie header,该规范将 Set-Cookie 定义为禁止的响应标头名称,必须从任何暴露给前端代码的响应中过滤掉。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.