1

I am having a tough time understanding how I can delete the whole cookie file that the website creates. I have the cookie at this location C:\Users\Test\AppData\Local\Microsoft\Windows\INetCache . It is being stored in this format cookie:Test@TestIdentity.net . Is it possible that I can delete this file using a javascript call.

My website is Test.net but the cookie that is saved is assigned through the Identity provider. So is it going to be an issue accessing the cookie.

I am using this function to iterate over the cookie

function get_cookies_array() {

    var cookies = {};

    if (document.cookie && document.cookie != '') {
        var split = document.cookie.split(';');
        for (var i = 0; i < split.length; i++) {
            var name_value = split[i].split("=");
            name_value[0] = name_value[0].replace(/^ /, '');
            cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]);
        }
    }

    return cookies;

}



 var cookies = get_cookies_array();
    for (var name in cookies) {
        console.log(name + " : " + cookies[name] + " ");
    }

This function is only giving me one Cookie but when I programatically check the Request.Cookies collection it has four cookies. I am not sure what I am doing wrong here.

The cookie contains Federation Authentication data.

Thanks

sp9
  • 755
  • 3
  • 11
  • 22

2 Answers2

0
<html>
<head><title></title>

<script type="text/javascript" language="javascript" >

var date = new Date();
date.setTime(date.getTime() + 30000);
document.cookie = "myVar=test; expires=" + date.toGMTString();
alert(document.cookie);

var expires = new Date();
expires.setTime(expires.getTime() - 1000);
document.cookie = "myVar=x; expires=" + expires.toGMTString();
alert(document.cookie);

</script>
</head>

<body>

</body>
</html>





var cookie = cookie_name + "=; expires=" + cookie_date.toGMTString() + "; path=/";      
parent.menu.document.cookie = cookie;
Rahul Sharma
  • 194
  • 1
  • 3
  • 18
0

In case somebody wonders why IE 11 doesn't delete a cookie, try removing the domain parameter:

// Before:
document.cookie = 'foo=; path=/; domain=example.com; expires=Thu, 01-Jan-1970 00:00:01 GMT'

// After:
document.cookie = 'foo=; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT'
Finesse
  • 9,793
  • 7
  • 62
  • 92