Came across this particular predicament today, wanted to delete a hostOnly cookie using the good old - 'set a past date as expires' trick.
But come what may, i was not able to delete a hostOnly cookie even by setting the expiry date to 2000.
A small code snippet.
var somePast = new Date(2000,03);
document.cookie="TARGET_COOKIE=asda; path=/ ;domain=subdomain.domain.com; expires="+today
And viola, the cookie was still there.
ON searching , came across this question , and the second answer said "If you have a hostOnly cookie, do not specify the domain when you modify/expire it."
and changing the code snippet as below
document.cookie ="TARGET_COOKIE=asda; path=/ ;expires="+today
It worked like a charm, bye bye hostOnly cookies !
答案 0 :(得分:0)
也许是因为您必须编写与创建它时完全相同的参数来删除(或编辑)它。