next.js 第三方Cookie失效日期

7vhp5slm  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(134)

我正在尝试使用JavaScript以编程方式检索第三方Cookie的到期日期。虽然我可以在浏览器的DevTools中查看到期时间(参见屏幕截图https://i.stack.imgur.com/BW072.png),但我无法弄清楚如何通过代码获取此信息。
我尝试使用“document.cookie”,但它只返回第三方cookie的值,而不是到期日期。有没有办法使用JavaScript获取到期日期?
我将非常感谢任何见解或代码片段,可以帮助我实现这一点。提前感谢!

gcxthw6b

gcxthw6b1#

fetch('https://example.com') // Replace with the URL where the third-party cookie is set
  .then(response => {
    console.log(response.headers.get('Set-Cookie'));
    // Parse the Set-Cookie header to extract expiry date information
    // Remember, not all servers provide this information in the header
  })
  .catch(error => console.error(error));

字符串

相关问题