WordType Designs
Driven To Distractions©
The Sound of One Hand Clapping©


A rchive Date
[ 10-06-2000 ]
Category
[ Information Technologies ]
sub-Categoy
[ Networking ]

      [COOKIE RETRIEVAL

      5.1 Introduction
      For the most part, retrieving cookies does not require reading the HTTP Cookie: header. Most languages read this header for you and make it accessible through a variable or object.

      Cookies can be read on the browser side or the server side. Again, the determining factor is the language used.


      5.2 Retrieving cookies with JavaScript
      To retrieve cookies with JavaScript, use document.cookie again. Typically, document.cookie has a string like so:

      foo=bar;this=that;somename=somevalue;.....

      This string contains every name-value pair valid for this document, separated by semicolons. This can make searching for your needed value a bit of a pain. The getCookie() function does make this simpler:

      function getCookie(name) {
      var cookie = " " + document.cookie;
      var search = " " + name + "=";
      var setStr = null;
      var offset = 0;
      var end = 0;
      if (cookie.length > 0) {
      offset = cookie.indexOf(search);
      if (offset != -1) {
      offset += search.length;
      end = cookie.indexOf(";", offset)
      if (end == -1) {
      end = cookie.length;
      }
      setStr = unescape(cookie.substring(offset, end));
      }

      }
      return(setStr);
      }


      The results are directed into variables in your routine:

      myVar = GetCookie("foo");

      Here, myVar would equal bar]


Some pages may require Adobe Acrobat Reader



Copyright and Fair Use Information: The contents of this web site is protected by international copyright laws and may not be reproduced in any form or manner whatsoever, if for the purpose of resale or solicitation of a donation. The essays included here, may be reproduced only if: 1)They are not altered in any way; 2) reproductions must be accompanied by this copyright page ; and 3) it is given freely and without charge.
Fair use: The fair use of copyrighted work, including such use by reproduction in copies or phonorecords or by any other means specified in above sections, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright. In determining whether the use made of a work in any particular case is fair use the factors to be considered include : (1) the purpose and character of the use, including whether the use is of a commercial nature or is for nonprofit educational purposes; (2) the nature of the copyrighted work; (3) the amount and substantiality of the portion used in relation to the copyrighted work as a whole, and; (4) the effect of the use upon the potential market value of the copyrighted work.

Home | About Narrative? |Contact
Copyright © 2025. All Rights Reserved
HAG122125 (1998 -2026)