Cookie question



Hey, I recently bought "The Javascript and DHTML Cookbook" by Danny
Goodman.

I'm at Chapter 1, part 1.9 "Reading and Writing Strings for Cookies"
and was just interested in a utility function that grabs a cookie
value:

function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1) {
endstr = document.cookie.length;
}
return unescape(document.cookie.substring(offset, endstr));
}

The part I don't understand is the if statement within the function,
why is it checking if endStr equals to false?

The book is kinda vague in explaining what this means! Any help would
be great.

Cheers

.



Relevant Pages

  • Vista Cookie Problems
    ... For the couple of hours I have been reading the great tutorials and yes ... even a sixty year old grand dad can still learn:geek: ... If thats not bad enought I'v cleaned 223Mbs of cookies after he ...
    (microsoft.public.windows.vista.general)
  • Re: Taking you out of the story revisited
    ... which is largely set in Scotland. ... I'm reading this at the ... minute and keep coming across children who are eating "cookies" and ...
    (rec.arts.mystery)
  • Re: unique sessions without mysql
    ... // in a login routine .....the usernames hash comes from reading a file // stored outside the document root, ... print the admin links..... ... the web server, and then log in as admin on any one of three ... I did nothing with cookies from my code at all. ...
    (comp.lang.php)
  • Re: Fetching cookie???
    ... #Change the directory to where your cookies are located ... #As an example I believe windows uses the following directory: ... The name and content is in the info array. ... So instead of reading each file individually you would open that single ...
    (comp.lang.ruby)
  • Re: unique sessions without mysql
    ... // in a login routine .....the usernames hash comes from reading a file // stored outside the document root, ... print the admin links..... ... I did nothing with cookies from my code at all. ...
    (comp.lang.php)