[thelist] JS cookie question (ignore previous)

Keith cache at dowebscentral.com
Mon Jan 13 12:09:01 CST 2003

At 11:34 AM Saturday 1/11/2003, Tom wrote:
>Keith that's great - just what I needed! Only 1 thing, I set up the
>following code below and simply used a fake string for the cookie (to
>test it). It worked perfectly except that it ran through the loop
>TWICE instead of once. I cannot for the life of me figure out why...
>function getCookieData(obj)
>coo = "aadf=asdf; asd%lk=23; pid111=2; pid231=4";
>cookies = coo.split(";");    //document.cookie.split(";");
>         for(i=0;i<cookies.length;++i)
>         {
>                 if(cookies[i].indexOf(obj) != -1)
>                 {
>                         thisCookie=cookies[i].split("=")
>                         alert(thisCookie[0]+"="+thisCookie[1])
>                 }
>         }

Perhaps you clicked it twice?? I copied the above and ran it, and it only
cycled once, until I clicked the

<a href=javascript:getCookieData("pid")>x</a>

the second time :-)

cache at dowebscentral.com

More information about the thelist mailing list