Click to go back HOME where it all starts.
A Zonie doesn't jump forward or spring back, but he does live in the last contiguous state to join the union.  Click to learn about marijuana, infamous governors, savings & loan debacles and more.
Look at MY pictures.
Miss America encounters MY WART, and I live to tell all about it.
The AHWATUKEE SIGN has a history unique in the annals of subdivision promotion.
The locations of the FIRST McDONALD's, the start of the original PSYCHO, the last act of BOB (Col. HOGAN) CRANE, the TRUNK and DUMPSTER murders ...
These forecasts and predictions are all based on solid, scientific, documented evidence....
Days between Dates, BFD Sound, learning the damn language ...

JavaScript Cookies Anyone?

A "cookie" is a bit of data stored on a client browser computer for later retrieval. On the best of authority, it's called a "cookie" for no good reason. That name is an improvement on its former name, "persistent client state HTTP cookie". The only reason this page is here is that I am trying to learn how to read and write cookies.

Read my cookie:
Cookie dies: (Must be set before cookie is stashed.)
When browser is shut down One week
Stash this in my cookie:

Heil JavaScript! (The commands)

document.cookie = [cookieNameString]=[dataString]; expires=[dateString]; path=[pathString]; domain=[domainString]; secure=[secureString];

[cookieNameString] As you would guess, the name of the cookie.

=[dataString]; The stuff you're saving. Put it is escape format [escape()] so as not to confuse the cookie retriever with errant semicolons and other stuff.

expires=[dateString]; Optional. If null, cookie expires when the browser is exited. The dateString must be of the form Wdy, DD-Mon-YY HH:MM:SS GMT, such as "Mon, 08-Jul-96 03:18:20 GMT". This is the format you get with "dateStringuse = new Date()", which you can then manipulate to add days in milliseconds ([number of days] * 24 * 60 * 60 * 1000 ). To delete a string, set the expiration date earlier than the present date.

path=[pathString]; Controls what pages may access the cookie. By default (if there is no path=pathString), cookies are available to other pages within the same directory as the page on which they were created. "path=/" makes the cookie available to every page on your server. If you provide a cookie path attribute, the browser will check it against your script's URL before returning the cookie. For example, if you specify the path "/cgi-bin", then the cookie will be returned to each of the scripts "/cgi-bin/tally.pl", "/cgi-bin/order.pl", and "/cgi-bin/customer_service/complain.pl", but not to the script "/cgi-private/site_admin.pl". By default, path is set to "/", which causes the cookie to be sent to any CGI script on your site.
Note: Everyone says that there is a bug in Netscape Navigator 1.1 & earlier which prevents cookies with an expiration date from being saved without the statement: path=/. I could not get cookies to be saved beyond the present session in Netscape 4.7 or Internet Explorer 5.0 without this statement.

domain=[domainString]; This is a partial or complete domain name for which the cookie is valid. The browser will return the cookie to any host that matches the partial domain name. For example, if you specify a domain name of ".capricorn.com", then Netscape will return the cookie to Web servers running on any of the machines "www.capricorn.com", "www2.capricorn.com", "feckless.capricorn.com", etc. Domain names must contain at least two periods to prevent attempts to match on top level domains like ".edu". If no domain is specified, then the browser will only return the cookie to servers on the host the cookie originated from.

secure=[secureString]; If null, the cookie will be sent unencrypted. If the parameter is present, the browser must support HTTPS - Netscape's Secure Socket Layer Web page encryption protocol. [Huh?]

Where are they saved? In Internet Explorer 4.0, cookies are stored in discrete little text files under c:\Windows\Profiles\<user name>\cookies\, and in c:\Windows\Temporary Internet Files\. Internet Explorer 3.0 saves them in c:\Windows\Cookies\. Netscape Communicator 4.0 puts all cookies in one text file: c:\Program Files\Netscape\Users\<user name>\cookies.txt.

Other cookie sheets:

See also Richard Wagner, JavaScript Unleashed, Sams.net Publishing (1977), p. 637 for a discussion of cookies which confused me enough to come up with this worksheet.

SO...now that my cookies are saved, let's try an Array

Arrays are simple in JavaScript 1.1, but they don't work in 1.0. This is the work-around.

What I really want to do is create an array of objects like, say the form fields above, not mere variables. As the page goes through the script, I have added some document.writeln()'s to report on its progress. (Silly me! I thought writeln was writein. It's amazing how much better the script runs when you use an "l" instead of an "i".)