Email conversation
From | NSaibot |
To | Me |
Subject | cookie stuff |
Date | 14 May 2004 12:31 |
Hi Mark,
as discussed before in the chat i need to store several id's in a cookie.
like: id1@id2@id3@
the algorithm:
if no cookie, create it. if there is a cookie but it does not have the
value, append to the value. if there is a cookie and it already has the
value, remove the id.
From | Me |
To | NSaibot |
Subject | Re: cookie stuff |
Date | 14 May 2004 13:04 |
this code assumes the cookie function names used in my cookie handling
script
It also assumes that the ends of the ID's are not similar (eg, id1 and aid1)
as you said this in the chat (id1 and id12 is OK)
function manipulateId(name,value) {
value = value+'@';
var currentStr = retrieveCookie(name);
if( !currentStr ) {
//store the id
setCookie(name,value);
} else if( currentStr.indexOf(value)+1 ) {
//delete from list of ids
value = new RegExp(value,'');
setCookie(name,currentStr.replace(value,''));
} else {
//add to list of ids
setCookie(name,currentStr+value);
}
}