[thelist] JS cookie question (ignore previous)
Tom Dell'Aringa
pixelmech at yahoo.com
Fri Jan 10 11:52:10 CST 2003
--- Hans-Frédéric Fraser <hfraser at videotron.ca> wrote:
> On 1/10/03 12:14 PM, "Tom Dell'Aringa" <pixelmech at yahoo.com> wrote:
> > pidMaxValue = 200;
> >
> > for(x=1; x<=pidMaxValue; x++)
> > {
> > cookieName = "pid" + x;
> > thisCookie = getCookieData(cookieName);
> > //write them out to see
> > }
> > ------------------------------------
> > Now my test cookie is pid111=1. My problem is I get these results
> > pulled:
> > ------------------------------------
> > pid1= (1=1)
> > pid11= (=1)
> > pid111= (1)
> > ------------------------------------
> > So it sees pid111 as a value for 1, 10, and 11 and 111 which is
> odd.
> > It's actually pulling apart the cookie to give me the = sign as
> part
> > of my response.
> >
> > Any idea why this is or how I can fix it?
>
> well your problem seems to be with the getCookieData() function!
> if we could have a look at it we might be able to help!
LOL..alrighty good point. Note I made a mistake above, I removed the
one line (pid107) - its just the three that get pulled.
Here is my getCookieData() function, courtesy of Danny Goodman:
----------------------------------------------
function getCookieData(labelName)
{
var labelLen = labelName.length;
// read cookie property only once for speed
var cookieData = document.cookie;
var cLen = cookieData.length;
var i = 0;
var cEnd;
while(i < cLen)
{
var j = i + labelLen;
if(cookieData.substring(i,j) == labelName)
{
cEnd = cookieData.indexOf(";", j);
if(cEnd == -1)
{
cEnd = cookieData.length;
}
return unescape(cookieData.substring(j+1, cEnd));
}
i++
}
return "";
}
-----------------------------------------
Might it have something to do with the cookie length? Its odd to get
results with the = sign in it...
Tom
=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
More information about the thelist
mailing list