Creating Web Apps  «Prev  Next»

Lesson 4 What exactly are cookies?
Objective Describe the characteristics of cookies.

What is an Internet Cookie on the WWW?


Why use Cookies?

Cookies are used to work around the HTTP protocol, in which the server retains no information about the state of a connection with a visitor, it simply drops that information. While that poses no problem for most Web activity, it is undesirable for transaction-based activities such as shopping online. For example, a user may fill a shopping cart one day and may want to come back another day to complete the transaction. Cookies help retain the state of transactions over time.
You will learn more about how cookies work in the following SlideShow.

Web Cookie Process

1) When a user visits a Web site, the URL of the web site is passed
1) When a user visits a website, the URL of the website is passed to the web server.

2) When visiting the website, the user performs an activity
2) When visiting the website, the user performs an activity such as buying a coat.

3) Information about what the user purchased, along with some personal information
3) Information about what the user purchased, along with some personal information about the user, is then sent to the web server.

4) The server then passes the cookie to the user's computer.
4) The server then passes the cookie to the user's computer.

5) The next time the user visits that web site, a banner ad for coats are displayed
5) The next time the user visits that web site, a banner ad for coats are displayed. This is one way cookies are used to customize a website based on information provided by the user.

User options

Preferences for accepting or rejecting cookies are set in the browser. Although the name of the options change from browser to browser; in general, users can set the following preferences:
  1. Do not allow cookies.
  2. Allow cookies.
  3. Ask each time.

Implications

Developers have no control over the preference settings in browsers of visitors. The implication is that site functionality could disappear if a site relies on the use of cookies and the visitor does not accept cookies. Developers must choose between providing two versions of the site: one for those who accept or allow cookies and one for those who do not. The alternative is to design one site and risk losing visitors.
In the next lesson, you will learn how cookies are created.

On Your Own

Click the link below to practice testing the effects of cookies on a Web site.
Testing Web Cookies

HTML 5