Docstoc

Cookies

Document Sample
Cookies Powered By Docstoc
					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
  and Settings.
• Use Windows Search to find Cookies files and
  folders
A Cookie File From Netscape




C:\Program Files\Netscape\Users\pmckeown\Cookies.txt
      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.
         Guestbook Application
• 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
     set preferences)
   – GBProc.asp (file used to process names and
     preferences)
   – Default.asp (the file that checks if a cookie exists or
     not)
   – Global.asa (the application file that glues everything
     together)
                  Default.asp
• 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 file.
• Cookie values are read through the
  Request.Cookies (“filename”)(“fieldname”)
  statement
• 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
  form there
                 GB.htm
• 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
  information
• Nothing real new
                  GBproc.asp
• 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
  Response.cookies(“filename”)(“fieldname”)
  statement
• Let’s start with the GB.htm file since it’s the basis
  of all other information.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:6
posted:10/24/2012
language:English
pages:9