Chrome中无法用JavaScript删除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
相关产品推荐
相关产品推荐

