safari 9 delete cookie issue

Hi,


I have a problem, I try to delete cookie use javascript


document.cookie = 'my_cookie=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';

// but my_cookie stille in document.cookie
console.log(document.cookie);
// output "my_cookie=;"

This is work in safari 8 or chrome or firefox, but in safari 9 is not work. Is bug?

How to delete cookie correctly?


my safari version : 9.0 (10601.1.43)

OS X Yosemite: 10.10.5(14F27)

Hi dian,


I am using safari 9, and found that document.cookies is document specific, if I do "document.cookies", I get only the cookies of the tab , in which I am working.

I am also a bit stuck here that how to get all the cookies available in the browser.


I am not sure but may be you are not able to delete cookies because of this same reason.


You may have solved this Issue , as it is almost a year old, If yes , Can you Please post your answer.

In my case, I need to specify domain when setting cookie

For example

When setting:
Code Block javascript
document.cookie='_session=123; domain=.localhost;';


When removing
Code Block javascript
document.cookie='_session=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.localhost;'


And it will work
safari 9 delete cookie issue
 
 
Q