Working with Cookies
What is a “Cookie”?
• According to Whatis.com a cookie is:
A cookie is information that a Web site puts on your
hard disk so that it can remember something about
you at a later time.
• In Netscape, a cookie file is stored in the
Cookies.txt folder in the Netscape folder.
• In IE, its in a Cookies Folder under Documents
• Use Windows Search to find Cookies files and
A Cookie File From Netscape
Cookies File in IE
C:\Documents and Settings\pmckeown\Cookies
Creating a Guestbook
Application with Cookies
• Let’s create the same Guestbook application
shown in the Dummies pp 174-181
• We will use a database rather than a
sequential access file
• Download the database file from the class
Web page along with the default.htm,
gb.htm, and gbproc.asp files. They are
zipped so you will need to unzip them.
• The Guestbook.zip file contains 6 files
– Guestbook.mdb (an Access 2000 file)
– DBConnect2000.asp (you should already have this)
– GB.htm (the file used to add names to guestbook and
– GBProc.asp (file used to process names and
– Default.asp (the file that checks if a cookie exists or
– Global.asa (the application file that glues everything
• Default.asp checks to see if a cookie exists and, if
it does, set preferences using data from the cookie
and welcomes the visitor
• If does this by checking the value of a field in the
• Cookie values are read through the
• If a cookie does not exist, this is the first visit to
site so it user is redirected to gb.htm to fill in the
• This is a standard html page with an input
form that is used to input information about
user to Guestbook.mdb
• It uses text boxes and listboxes to solicit
• Nothing real new
• This file adds a new record to the Guestbook.mdb
file using the Insert Into SQL Statement
• It also sets preferences in cookie based on those
expressed by visitor.
• Preferences are set in the cookie through the
• Let’s start with the GB.htm file since it’s the basis
of all other information.