previous | start | next

Cookies

A cookie is a small "piece" of information (in fact, a string of characters) which a server can store "within" a Web browser. For example, the following response header (sent in addition to any other HTTP response headers) "sets" a cookie in the user's browser:
HTTP/1.1 200 OK
Set-cookie: SID=XYZZY8765765vk5ht
   ...other response headers
All subsequent accesses to the same server (and by the default, the same response entity that generated the cookie) will include the cookie sent as the value of an additional request header, eg:
GET http://www.asdf.com/example.cgi HTTP/1.1
Cookie: SID=XYZZY8765765vk5ht
   ...other request headers
Each cookie can have several extra attributes, separated by semicolons:
 
Name=Value
this attribute is compulsory, and more than one is allowed. Both "Name" and "Value" can be any ASCII string.
 
expires=DATE
defines the lifetime of the cookie. Default is the current browser session, specifying a time in the future means a cookie is stored "in" the browser. Example: expires=Sun, 31 Dec 2005 23:59:59 GMT
 
domain=DOMAIN
an Internet domain name to which this cookie may be sent. This is normally used to broaden the range of servers that a cookie will be sent to. Example: domain=latrobe.edu.au
 
path=PATH
defines the subset of URLs within a domain for which this cookie is valid and may be sent. Normally used to broaden the range of accesses to a server (or domain) to which a cookie will be sent. Example: path=/

 
Lecture 8: Web Commerce Technologies Copyright © 2005 P.Scott, La Trobe University Bendigo.


previous | start | next