You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chrome中无法用JavaScript删除CHIPS分区Cookie的问题咨询

关于CHIPS分区Cookie删除的问题

由于第三方Cookie弃用政策,我已使用CHIPS将应用中的部分Cookie设置为“分区”状态,示例设置代码如下:

function setPartitionedCookie() {
  document.cookie =
    "cookie=delicious; Max-Age=86400; Path=/; Secure; SameSite=None; Partitioned;";
}

我尝试通过将Expires属性设为过去日期的方式用JavaScript删除该Cookie,但在Chrome 123版本中,若不同时指定Secure和Partitioned属性则无法成功删除:

function deletePartitionedCookie() {
  /* "Secure" and "Partitioned" attributes are required to delete the partitioned cookie in Chrome */
  // document.cookie = "cookie=; Expires=Thu, 01 Jan 1970 00:00:00 UTC; Secure; Partitioned;"; // 此代码在Chrome中有效

  document.cookie = "cookie=; Expires=Thu, 01 Jan 1970 00:00:00 UTC;"; // 此代码在Chrome中无效
}

此前我了解到,删除Cookie有时需要指定对应的Path和Domain属性,但不清楚具体适用场景。请问上述Chrome中的行为是设计如此还是Bug?删除CHIPS分区Cookie的正确方法是什么?

补充:Firefox和Safari暂不支持Partitioned属性,暂未出现该问题,尚未测试Edge。

内容的提问来源于stack exchange,提问作者glmvc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 21:52:10