Redirects the visitor to different pages based on the value of a stored cookie. If no cookie is found, the available items are displayed for the user to pick from, which sets a cookie for their next visit. Our demonstration uses a 'favorite animal' cookie, but this could easily be modified to fit your needs.
Add the below code to the <body> section of your page:
<scriptlanguage="javascript"type="text/javascript"> /* Visit http://www.yaldex.com/
for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin var
expDays =30; varexp=newDate(); exp.setTime(exp.getTime()+(expDays*24*60*60*1000));
function
getCookieVal (offset){ var
endstr =document.cookie.indexOf(";",offset); if(endstr
==-1)
endstr =document.cookie.length; returnunescape(document.cookie.substring(offset,
endstr));
} function
GetCookie (name){ var
arg =name+"="; var
alen =
arg.length; var
clen =document.cookie.length; var
i =0; while(i
<
clen){ var
j =
i +
alen; if(document.cookie.substring(i,
j)==
arg) return
getCookieVal (j);
i =document.cookie.indexOf("
",
i)+1; if(i
==0)break; } returnnull;
} function
SetCookie (name,value){ var
argv =
SetCookie.arguments; var
argc =
SetCookie.arguments.length; var
expires =(argc
>2)?
argv[2]:null; var
path =(argc
>3)?
argv[3]:null; vardomain=(argc
>4)?
argv[4]:null; var
secure =(argc
>5)?
argv[5]:false; document.cookie=name+"="+escape(value)+ ((expires
==null)?"":(";
expires="+
expires.toGMTString()))+ ((path
==null)?"":(";
path="+
path))+ ((domain==null)?"":(";
domain="+domain))+ ((secure
==true)?"; secure":"");
} function
DeleteCookie (name){ varexp=newDate(); exp.setTime(exp.getTime()-1); var
cval =
GetCookie (name); document.cookie=name+"="+
cval +"; expires="+exp.toGMTString();
}