HowTo Delete Cookie Using Javascript
Usually server-side code on dynamic web pages is responsible to manage client cookies (store and delete them). However it is also possible to provide a certain control for cookie management from client code. This is a small javascript trick that demonstrates how to delete cookie using client code. Cookie simply is updated as expired and removed.
< html> < head> < title>< /title> < script language="Javascript"> function loaded() { document.cookie = "v0=1;"; document.cookie = "v1=2;"; alert(document.cookie); } function deletecook() { var d = new Date(); document.cookie = "v0=1;expires=" + d.toGMTString() + ";" + ";"; alert(document.cookie); } < /script> < /head> < body onload="loaded();"> < a href="javascript:deletecook();">delete cookie< /a> < /body> < /html>
Sunday, May 23, 2004 5:55 AM