NSaibot

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromNSaibot
ToMe
Subjectcookie stuff
Date14 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.
FromMe
ToNSaibot
SubjectRe: cookie stuff
Date14 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);
    }
}
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.