- Definition - "A cookie is a small, customized piece of
information that a Web site stores on a visitor's hard drive. Through
a browser, a cookie can be stored, retrieved, and deleted. A cookie
has only one purpose: to remember information about an individual
visitor." pg 117 from "Designing with JavaSciript" by
- document.cookie object.
- Has 5 properties:
- name=value (manditory)
- expires=timeInGMT (optional)
- path=pathName (optional)
- domain=domainName (optional)
- secure (optional)
- Of the 5 properties you can only retrieve the name/value
- Example: document.cookie= "username = " +
escape("Michael Thomas") + ";"
This cookie is named "username" and has the value
"Michael Thomas". No other properties were set.
- A Netscape cookie file can contain a max of 300 cookies.
- With Netscape, each domain (ie: yahoo.com) can have a max of 20
- Each cookie has a max of 4 kbytes. It is advisable to keep each
name/value pair to less that 2 kbytes.
can see is those from that same domain as the HTML file that the
see the the cookies create by another domain (ie:
www.michael-thomas.com). This is a security feature.
- Cookie Expirations Date
- Expiration Date must be passed as Greenwich mean time (GMT).
You can use the Date's .toGMTString() function for this.
- When the browser is launched, the browser will clear all cookies
that have expired past the expire value that the programmer gave the
- Navigator - If you do not specify a expiration date, the cookie
stays in memory but is never written to the cookie file! Its a
- Visibility of Cookies to other HTML files within a Domain.
- Use the "path" & "domain" property to
share cookies between HTML files in different directories within a
- Domain property. Must have at least two periods. (ie:
.yahoo.com or http//www.yahoo.com). If you leave the domain
property empty, the browser will create it for you.
- Cookie Preferences
In Nav 4.6 - Edit, Preferences, Advance. Next you will see a
section for cookies and several properties. I use "accept all
cookies" (I think this was the default).
1) Accept all cookies
2) Accept only cookies that get sent back to the originating
3) Disable Cookies
You can also set: Warn me before accepting a cookie.
- Cookie Files - cookies.txt in Netscape's Program
directory. The one file contains all of the cookies for all of the
domains. There is one file per Netscape's Communicator profile.
- Deleting Cookies - Remember that all of the cookies for all
of the domains are in one file.
- Edit, Preferences, Advanced, Cache
- Click on "Clear Disk Cache".
- Click on "Clear Memory Cache".
- Now exit the browser. (Note: As of 4.6, I've
noticed that the cookies remain until the browser is closed.
- Cookie Preferences
In IE 5.0 - Tools, Internet Options, Security. Then choose the
zone you want to change (ie: Internet, Local Internet,
etc...). Next click on "Custom Level". Now scroll
to the section on "Cookies".
- Allow cookies that are stored on your computer. (default
- Allow per session cookies (not stored). (default =
- Cookie Files
IE - Cookies are stored in separate files under a subdirectory of the
windows load directory. (Tools, Internet Options, General,
Temporary Internet Files: Settings, View Files. Now search for a
file name that starts with "cookie:". You'll also see
all of the cached html pages.)
- Deleting Cookies - IE creates a file for each domain (ie:
- Tools, Internet Options, General, Temporary Internet Files
- Deleting cached HTML pages (not cookies): If you want to
delete all of the cached html pages click on delete files.
This will not delete the cookies, but it will make it easier to see
just the cookies in the next step.
- Now, click on "Settings"
- Directory of Files: If you would like to know the directory
the files are located in look for the words "current
- Now click on "View Files"
- You'll notice that there is are files that begin with
"cookie". On WinNT you will also see one file per
"UserID" for a domain (ie: www.yahoo.com).
- Now select the cookie files for the domains that you want to
delete and press the "Delete" key. If deleted
multiple files at one time it appear like the files were not
deleted, that is a bug. Click on OK, then "View
Files" again and you'll notice that they are deleted.
- Cookie Object - document.cookie
Heinle, published by O'Reilly.
- Chapter 8 Customizing a Site with Cookies. Excellent
presentation and good code examples.