
/******************************************************************************
delete_cookie (name)
delete_cookie (name, path)

delete_cookie deletes the cookie with the specified name and path by setting it's ecpiration date in the past.  If no path is given, the default cookie path for the current document is used instead.  If the name and path do not match an existing cookie, delete_cookie has no effect.
******************************************************************************/

function delete_cookie (name, path)
{
	// Build expiration date string:
	var expiration_date = new Date ();
	expiration_date . setYear (expiration_date . getYear () - 1);
	expiration_date = expiration_date . toGMTString();

	// Build set-cookie string:
	var cookie_string = escape (name) + "=; expires=" + expiration_date;
	if (path != null)
		cookie_string += "; path=" + path;

	// Delete the cookie:
	document . cookie = cookie_string;
}



/******************************************************************************
delete_all_cookies ()
delete_all_cookies (path)

delete_all_cookies deletes all cookies matching the specified path.  If no path is supplied, the document's default cookie path is used.
******************************************************************************/

function delete_all_cookies (path)
{
	// Get cookie string and separate into individual cookie phrases:
	var cookie_string = "" + document . cookie;
	var cookie_array = cookie_string . split ("; ");

	// Try to delete each cookie:
	for (var i = 0; i < cookie_array . length; ++ i)
	{
		var single_cookie = cookie_array [i] . split ("=");
		if (single_cookie . length != 2)
			continue;
		var name = unescape (single_cookie [0]);
		delete_cookie (name, path);
	}
}
