0

I'm deleting cookies with javascript with this code

var arrCookies = document.cookie.split(';');
for(var i = 0; i < arrCookies.length; i++){

                var key = arrCookies[i].split("=");
                //var new_value = key[0].trim()+"=; expires = Thu, 01 Jan 1970 00:00:00 UTC;path=/; domain=mydomain.com";
                //document.cookie = new_value;
                var new_value = key[0].trim()+"=; max-age=0; path=/; domain=.mydomain.com"; 
                document.cookie = new_value;
                new_value = key[0].trim()+"=; max-age=0;path=/; domain=.dev.mydomain.com";  
                document.cookie = new_value;
                new_value = key[0].trim()+"=; max-age=0;path=/; domain=dev.mydomain.com";
                document.cookie = new_value;
        }

But there are some cookies that are note deleted its cookies are HostOnly ,I don't know if it's a coincidence, its possible to delete hostonly cookies?How?

afccc
  • 79
  • 4

1 Answers1

0

HostOnly cookies are accessible only from the same domain and subdomain (so HostOnly cookie from foo.example.com cannot be read and written to by example.com).

More on the HostOnly parameter here: https://stackoverflow.com/a/28320172/3303059

Make sure the cookies you are trying to modify aren't HttpOnly. Such cookies are sent in the HTTP headers only and aren't accessible directly by JavaScript. These are usually session login tokens and this flag protects them from XSS vulnerabilities (since any injected external JS cannot read them anyway).

ericek111
  • 402
  • 3
  • 11