首页 > 解决方案 > 带有 `document.cookie` 与 `cookieStore.get` 的 Cookie 属性

问题描述

如果我使用 设置具有某些属性的 cookie,如果我使用 cookie而不是使用document.cookie访问 cookie,则会向我报告它们:cookieStore.getdocument.cookie

    document.cookie = ">>>Test123=Hello there; Secure; SameSite=Lax";
    console.log(document.cookie);
    cookieStore.get(">>>Test123").then(console.log);

document.cookie给出:

>>>Test123=Hello there

cookieStore.get给出:

{
  domain:null,
  expires:null,
  name:">>>Test123",
  path:"/834420",
  sameSite:"lax",
  secure:true,
  value:"Hello there"
}

有没有办法在SameSite不使用的情况下获取例如 cookie 的属性的信息cookieStore

我在这里有代码:https ://playcode.io/834420/如果有帮助

标签: javascriptcookies

解决方案


推荐阅读