1

I am having weird issue with IE10. IE10 is sending expired JSESSIONID cookie for authentication causing the login filure, So am trying to delete the JSESSIONID cookie as below

function getCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i<ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1);
            if (c.indexOf(name) != -1) {
                return c.substring(name.length, c.length);
            }
        }
        return "";
    }
    if(getCookie("JSESSIONID"))
        {
        var c = getCookie("JSESSIONID")
            console.log("JSESSIONID = "+ c)
            document.cookie = c + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
        }

Whenever I reload the page I see JSESSIONID = A64F97BF3AF662AC56238F2C23D529AA in the console log instead of JSESSIONID = A64F97BF3AF662AC56238F2C23D529AA=; expires=Thu, 01 Jan 1970 00:00:01 GMT;

Can someone please help me to fix this issue?

OTUser
  • 3,788
  • 19
  • 69
  • 127

1 Answers1

2

You're keeping the old cookie value and adding = to the end of it. You should be setting the value to an empty string:

document.cookie = 'JSESSIONID=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • I changed it to `document.cookie = 'JSESSIONID=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';` but still am seeing `JSESSIONID = A64F97BF3AF662AC56238F2C23D529AA` in the console when I refresh the page – OTUser Oct 07 '14 at 16:17
  • Search for `[javascript] delete cookie` for other questions that show how to delete cookies. – Barmar Oct 07 '14 at 18:15