[thelist] Trashing a JS cookie

Chris George cgeorge at basecorp.com
Tue Oct 14 14:30:54 CDT 2003


Hey all,

I need to trash a JS cookie. I'm not that well versed in JavaScript, and
mostly just fuddle my way through the code guess-and-check style.
However, I have consulted some online JS resources, and their code does
not match the code I have on my end (that another developer wrote).
Specifically, I have:

function createCookies()
{
		var queryString=document.location.href;
		queryString=queryString.toString();
		queryString=
queryString.substring(queryString.indexOf("?")+1,queryString.length+1);
			var aPermSet=queryString.split("&");
			for(var a=0;a<=aPermSet.length-1;a++)
			{
				if(aPermSet[a].indexOf("operator")>=0)
				{
					atemp=aPermSet[a].split("=");
	
operator=atemp[1].substring(0,atemp[1].length+1);
	
document.cookie="operator="+atemp[1].substring(0,atemp[1].length+1)
				}
				if(aPermSet[a].indexOf("basic")>=0)
				{
					atemp=aPermSet[a].split("=");
	
basic=atemp[1].substring(0,atemp[1].length+1);
	
document.cookie="basic="+atemp[1].substring(0,atemp[1].length+1)
				}
				if(aPermSet[a].indexOf("full")>=0)
				{
					atemp=aPermSet[a].split("=");
	
full=atemp[1].substring(0,atemp[1].length+1);
	
document.cookie="full="+atemp[1].substring(0,atemp[1].length+1)
				}
				if(aPermSet[a].indexOf("gloss")>=0)
				{
					atemp=aPermSet[a].split("=");
	
gloss=atemp[1].substring(0,atemp[1].length+1);
	
document.cookie="gloss="+atemp[1].substring(0,atemp[1].length+1)
				}
			}
}

And I need to delete it onUnload. However, from what I understand, you
need to refer to the cookie by name, and from what I can see, that
cookie doesn't have one. So... I don't really know what to do/where to
start.

Can anyone help me?


More information about the thelist mailing list