anderlecht
asked on
How to delete immediately a cookie ?
I try to delete my cookie by setting the expire date in the past. That works but the cookie is deleted only when I exit the browser. How can I delete immediately a cookie in javascript ?
ASKER
That method doesn't work with IE5.5. The cookie is deleted only if you quit the browser.
than it should be the issue of the browser ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
haha ... may be than we can check the value of the cookie and if it is empty, than treat like as it does not exist ~ haha ...
Exactly. That is the way to do it:
cook=getCookie('nameOfCook ie')
if (cook) alert('nameOfCookie:'+cook )
else alert('nameOfCookie not set or empty')
Michel
cook=getCookie('nameOfCook
if (cook) alert('nameOfCookie:'+cook
else alert('nameOfCookie not set or empty')
Michel
haha ... thx mplungjan to clarify my concept :)
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
points to mplungjan
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
ahosang
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
points to mplungjan
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
ahosang
EE Cleanup Volunteer
per recommendation
SpideyMod
Community Support Moderator @Experts Exchange
SpideyMod
Community Support Moderator @Experts Exchange
<html>
<head>
<title>test delete cookie</title>
<script type="text/javascript" language="JavaScript">
<!--
function setCookie()
{
document.cookie = "testcookie=testing";
}
function delCookie()
{
document.cookie = "testcookie=;expires=Fri, 02-Jan-1970 00:00:00 GMT";
}
function readCookie()
{
alert(document.cookie);
}
//-->
</script>
</head>
<body>
<a href="javascript:setCookie
<a href="javascript:delCookie
<a href="javascript:readCooki
</body>
</html>