ASP Cookies: Usage, Reading, and Management, Slides of Fundamentals of E-Commerce

An in-depth exploration of cookies in asp, including how to read and write dictionary cookies, cookie concepts, detecting cookie acceptance, when cookies go bad, uses of cookies, client-side cookies, and cookie management and gotchas. It also discusses the benefits and concerns of using cookies.

Typology: Slides

2012/2013

Uploaded on 07/30/2013

shoki_sho
shoki_sho 🇮🇳

4.9

(7)

121 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Reading Cookies with ASP
Determining a dictionary cookie (Returns true/false)
CkDict = Request.Cookies("MyCookie").HasKeys
Determine the dictionary Cookie keys count with
Mycount = Request.Cookies("MyCookie").Count
Read dictionary cookie values by subkey or index.
Myval = Request.Cookies("MyCookie")("1stval")
Myval = Request.Cookies("MyCookie")(1)
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download ASP Cookies: Usage, Reading, and Management and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Reading Cookies with ASP

•^

Determining a dictionary cookie

(Returns true/false)

CkDict = Request.Cookies("MyCookie").HasKeys •^

Determine the dictionary Cookie keys count with Mycount = Request.Cookies("MyCookie").Count •^

Read dictionary cookie values by subkey or index. Myval

= Request.Cookies("MyCookie")("1stval")

Myval

= Request.Cookies("MyCookie")(1)

Reading Cookies with ASP

•^

Read all values in a dictionary cookie by iteratingthrough the subkeys. For Each key

in Request.Cookies("MyCookie")

Response.Write key & "-" & _Request.Cookies("MyCookie")(key) Next •^

Reading a non-existent key from a dictionary cookiereturns null. Use .HasKeys to avoid errors.

Cookie Concepts

•^

Cookies persist

only

as long as the client's

browser is open

unless

an expiration date is

explicitly added to the cookie.

-^

Cookies are only available to thedomain/webserver that created them.

-^

Cookies will be sent to any subdomain within thelast two segments of the domain name, e.g., acookie for www.microsoft.com is also available tohome.microsoft.com and msdn.microsoft.com.

Cookie Concepts

•^

Cookies should not exceed 255 characters and 4KB insize, and best practice is to make them as small aspossible.

-^

For Netscape browsers, a specific domain can onlyset a maximum of 20 cookies on the client.

-^

Do not write information cookies that could becompromising to the client, e.g., credit cardnumbers, etc.

-^

Domain and Path properties can be very sensitive tocase. Best to avoid using when possible.

When Cookies Go Bad

•^

Cookie expires.

-^

User replaces hard drive or computer.

-^

Client deletes cookies.

-^

Client’s browser deletes cookie because has morethan 300 cookies.

-^

Client configures browser to not accept cookies.

-^

Client’s LAN/firewall prevents setting or readingof cookies.

When Cookies Go Bad - 2

•^

Client uses different browser software.

-^

Client uses a different computer.

-^

A different user uses the client’s browser.

-^

Cookie file becomes corrupted/damaged.

Client-Side Cookies

•^

JavaScript supplies a built-in object calleddocument.cookie to handle cookie interaction. Thisobject will store all the valid cookies for the givenpage the script is running on.

Cookies Subverting the World?

•^

Many people unnerved by webservers writinganything to their machines.

-^

Bigger concerns about tracking the client's activitiesin a site – this can is good or bad depending uponhow it is used.

-^

There have been some bugs in cookieimplementations, e.g., email address was available inone version of Netscape.

Cookie Gotchas

•^

In ASP pages, must write cookie before the HTMLelement or enable buffering.

-^

In ASP pages, alleged bug in response.cookiesmethod may allow writing out value only once.

-^

Cookie will expire at end of client’s browsersession unless you set its Expires property.

-^

Always rewrite all values of a dictionary cookie.

-^

Your pages may need to deal with browsers thatdon't support cookies.

-^

The Domain and Path properties are VERY casesensitive.