Unable to delete cookie from javascript

后端 未结 6 1183
名媛妹妹
名媛妹妹 2021-01-01 09:35

I am on an external site, and I am trying to delete the cookie via javascript.

I did the following in the console:

function deleteAllCookies() {
             


        
6条回答
  •  感情败类
    2021-01-01 10:10

    I had the same issue. I discovered that the cookie was set under an empty subdomain, e.g. the cookie domain was ".domain.com", and my website was hosted at "sub.domain.com".

    To fix I added the cookie domain to the set value

    document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=.domain.com";
    

    To see what domain the cookie is set to, in Chrome, open dev tools -> resources -> cookies and look at the domain fields.

提交回复
热议问题