Databases and Cookies
(Page 1 of 13 )
Learn about two of the cornerstones of programming applications for the Web: Databases and Cookies. The first section is a review for those not familiar with the subject. Jump to the section titled "Using Cookies with ADO and a Database" for some advanced action. (This is chapter 11 of
Beginning ASP Databases by Kauffman, Spencer, and Willis; Apress, ISBN 1590592492.)
Databases and Cookies
From a programmer's standpoint, one great problem of the web is the lack of an intrinsic identification of visitors. Cookies provide a means of identifying visitors, with their approval, so that continuity can be established between visits. Cookies are limited in the amount of information they can hold but, by storing an identification number in a cookie, we can then use that ID with ASP-ADO to look up a returning visitor in our database, and thus have all of the visitor's data available.
Review of Cookies The following section provides a review of the purpose of cookies and a few key points to remember about cookies. If you have been working with ASP pages for very long you are probably already familiar with the basics and can skip to the section entitled "Using cookies with ADO and a Database." The topic of cookies is also covered in depth in Beginning and Professional Active Server Pages (ISBN 1-861001-34-7 and 1-861001-26-6) with additional information on cookies in the context of sessions and applications.
Purpose of Cookies Cookies were created to overcome the problem of identifying visitors to the site for the purpose of maintaining some continuity between requests. There is no mechanism built into the World Wide Web that states the name of the PC that is sending a request, or that provides the ability to sense that a series of requests are all coming from the same visitor. Recall that the WWW was originally designed to provide rapid and universal access to pages of information. There was no need for a system to track a series of requests as being from the same user. Implementation of that type of continuity would slow down the server.
However, modern sites provide a more interactive experience, which frequently requires that the server has an identification of the visitor. For example, visitors may proceed through many pages of forms to place an order; the server will have to know which was the last page completed by that user and be capable of holding information between submissions. Cookies were designed to hold information about a user, including an identifying number. When a visitor returns to a site after a few minutes or a few years the site can identify that user and serve appropriate pages.
This is from Beginning ASP Databases by Kauffman, Spencer, and Willis (Apress, ISBN 1590592492). Check it out at your favorite bookstore today.
Buy this book now. |
Next: Key Points About Cookies >>
More ASP.NET Articles
More By Apress Publishing