Web Cookies (A.K.A.: Browser Cookies, HTTP cookies)
Why do we need cookies?
What is a cookie?
How does a cookie look like?
How does it work?
Cookies, e-commerce and e-banking
How do we control cookies?
Why Do We Need Cookies? WEB SERVER Ana John Peter browser browser browser HTTP HTTP (Hypertext Transfer Protocol) HTTP www.apwebco.com
Internet Browser and Web Server communicate trough HTTP protocol which is stateless
Often we need to maintain state on the server-side (user identity, preferences, shopping cart, activity, etc)
One method of maintaining state between HTTP requests is using cookies
What Is a Web Cookie?
Web Cookie: a small piece of text generated by the web server and sent to the browser
Upon receiving the cookie, the browser:
Stores the cookie in memory
Sends the cookie back to the web server each time it requests a new web page
How Does a Cookie Look Like?
A cookie is a name-value pair:
cookie name = cookie value
sessionID = AAA22311
languagePreference = EN
headerColor = BLUE
How Does It work
Consider a user that browses a news website
Upon first page request (first visit), the web server issues a cookie (e.g. sampleCookie=A1A211 )
The server sends the cookie and the page requested back to the browser
The browser stores the cookie in memory and sends it back to the server with each subsequent request
The server inspects each request; if the cookie is present, the server is able to maintain state regarding the user (identity, preferences, activity etc)
How Does It work sampleCookie=A1A211 sampleCookie=A1A211 News page, please! News page, and COOKIE sampleCookie=A1A211 Business page, please! ( sampleCookie=A1A211 ) Business page Sports page, please! ( sampleCookie=A1A211 ) Sports page browser WEB SERVER www.apwebco.com
Cookies and e-commerce
Consider an e-commerce site that sells cosmetics and apparel
Upon first request (visit) each online shopper (browser) receives a unique cookie. The server ties each cookie to an individual shopping cart (data structure)
The server inspects each subsequent request, reads the cookie and updates the shopping cart associated with that cookie
Cookies and e-commerce Ana John Lipstick page, please! Lipstick page AND the cookie SessionID=A1A211 SessionID=A1A211 COOKIE: SessionID=A1A211 Socks page, please! Socks page AND the cookie SessionID=BBB333 SessionID=BBB333 COOKIE: SessionID=BBB333 Ana’s shopping cart John’s shopping cart browser browser WEB SERVER www.apwebco.com