CIS 451: Cookies - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

CIS 451: Cookies

Description:

cookies are part of both the Request and Response ASP intrinsic objects ... (need to control buffer if any output will be written prior to create/delete cookies) ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 9
Provided by: RalphWe2
Category:
Tags: cis | cookies

less

Transcript and Presenter's Notes

Title: CIS 451: Cookies


1
CIS 451 Cookies
  • Dr. Ralph D. Westfall
  • January, 2001

2
Problem
  • server primarily tracks requests for files
  • efficient for high volume of users
  • usually doesn't know who is asking for files
  • even if from link on file in same application
  • need to send identification with request
  • identification needs to associated with all files
    requested by same user of application
  • can go in HTML form "hidden fields"

3
Possible Solutions
  • password login
  • advantage highest security
  • disadvantage extra work for customer
  • automated identification
  • could generate a random to ID customer
  • advantage no extra work for customer
  • disadvantage only good for one session
  • can' track repeat visits by same person

4
Another Solution Cookies
  • information stored in file on client computer
  • advantages
  • user only needs to enter data one time
  • data "persists," so it is available in later
    sessions
  • disadvantages
  • some users won't allow cookies
  • cookies can be removed from user's computer
  • replaced by newer ones, or manually cleared

5
Cookies
  • cookies have names
  • a cookie can have multiple values
  • cookie data is accessed by the cookie name, and
    the keys if more than one value
  • cookies are part of both the Request and Response
    ASP intrinsic objects
  • created by Response.Cookies methods
  • stored in Request.Cookies "collection"

6
Working with Cookies
  • (need to control buffer if any output will be
    written prior to create/delete cookies)
  • lt Response.Buffer true gt 'at top of file
  • creating
  • Response.Cookies("cookie")("key") "value"
  • 'substitute "literals" or string variables for
  • 'items within " "
  • deleting
  • Response.Cookies("cookie").Expires Date - 1000
  • 'deletes on client, still in current session

7
Working with Cookies - 2
  • accessing
  • strValue Request.Cookies("cookie")("key")
  • 'note that data is accessed from Request object
  • testing to see if multiple values of cookie data
    are available
  • blnValue Request.Cookies("cookie").HasKeys
  • 'blnValue true if number of values gt 1

8
Cookie Exercise
  • download cookiedata.asp and cookietest.asp from
    Code Samples
  • add some more input fields to cookiedata.asp and
    modify cookietest.asp to output these new fields
Write a Comment
User Comments (0)
About PowerShow.com