[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?]
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".)