This is what I use to save a set of user options on a webpage delimited by the "|" symbol. You could have counter values instead of options and zero those counters if the cookie didn't exist.
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
and
if (retCookie.length > 10) { // Cookie was valid
crumbs = retCookie.split("|");
document.nwcform.NoteDur.selectedIndex = crumbs[0];
document.nwcform.bIsDot.checked = crumbs[1];
document.nwcform.A1[crumbs[2]].checked = true;
document.nwcform.selAll.checked = crumbs[3];
document.nwcform.FretQwikCh.checked = crumbs[4];
..... ; }
else { //No or invalid cookie
document.nwcform.selAll.checked = true;
document.nwcform.namCrdC.checked = true;
document.nwcform.A1[1].checked = true; }
var my_cookie = "";
my_cookie += document.nwcform.NoteDur.selectedIndex + "|";
my_cookie += ((document.nwcform.bIsDot.checked) ? 1 : 0 ) + "|";
my_cookie += readStrum() + "|";
my_cookie += ((document.nwcform.selAll.checked) ? 1 : 0 ) + "|";
.....
setCookie("WPGuiChord",my_cookie,91); //Set for three months
HTH