PDA

View Full Version : delete cookie then close



monkeyboy
01-27-2006, 11:12 AM
Hi there. I'm trying to write a script that will delete a cookie called 'access' then close the popup window. Having a bit of trouble... this is what I've got so far:




<script>
ByeThen() {
eraseCookie('access')
function eraseCookie(name)
{
createCookie(name,"",-1);
}
window.close()
}
</script>


Cheers :)

TwoD
01-28-2006, 03:19 AM
why not just do document.cookie=""?
That would clear the whole cookie file I think.

monkeyboy
01-28-2006, 09:43 AM
Thanks TwoD... thing is I'm having trouble writing it into a script that I can call from a text 'close' link. Where do I name the cookie I want to delete? Cheers, P.

TwoD
02-01-2006, 01:55 AM
Cookies have no names, and you can only have one per page.
You can set name/value pairs in them and then separate them using cookieString.split("=").
More about cookies here:
http://www.quirksmode.org
Go to JavaScript->Miscellaneous scripts->Cookies