Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: "Tony" Newsgroups: comp.lang.javascript Subject: Why is it not possible to remove a session cookie with this code Date: Wed, 23 Jan 2013 16:57:00 +0100 Organization: A noiseless patient Spider Lines: 1 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Injection-Date: Thu, 24 Jan 2013 11:53:37 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="e11d5f05844091a833f7cabe8023bf0c"; logging-data="22410"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2yIhVAzjYatDklSdnzIq6szH2n5LxEPs=" X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3555.308 X-Newsreader: Microsoft Windows Live Mail 15.4.3555.308 Importance: Normal Cancel-Lock: sha1:MUvaYmm4zB9PKDuqdn7GzKc9YWM= X-Priority: 3 X-MSMail-Priority: Normal Xref: csiph.com comp.lang.javascript:18240 I create a cookie by using writeCookie function and I read the cookie by using the readCookie function. You can see the functions below. This works good and I use IE 10 Now I want to remove the session cookie without having to close down the browser and I use function deleteCookie. The problem is that if I delete an existing cookie by using deleteCookie function and then read the cookie by using readCookie the cookie is still existing despite having tried to delete it. Can anybody help me with that ? function deleteCookie(key) { document.cookie = key + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; } function writeCookie(name, value) { document.cookie = name + "=" + value + "; path=/"; } and I read the cookie by using this function function readCookie(name) { var i, c, ca, nameEQ = name + "="; ca = document.cookie.split(';'); for (i = 0; i < ca.length; i++) { c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1, c.length); } if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length, c.length); } } return ''; } //Tony