@denisl That works fine by me but there are a couple of superfluous lines in the code.
var thecookie = document.cookie.split(";")
for (var i = 0;i < thecookie.length;i++)
document.cookie = thecookie[i] + "=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/; domain=.domain.com;";
You don't need the date variables as you have hard coded the date as Thu, 01-Jan-70 00:00:01 GMT.
I'm using that called by a link.
I'm just trying to persuade my shared server to let me use mail() to send a message if anyone actually uses the cookie clearing function.