What are cookies?
Cookies are a standard mechanism that allows a Web site (or server) to deliver simple data to a client (or end user); request that the client store the information; and, in certain circumstances, return the information to the Web site. Cookies are a way of storing persistent client data so that a site can maintain information on a user across HTTP connections. ("Persistent" means that the information from the Web site lasts longer than the immediate connection.)
How do cookies work?
Cookies are small data structures delivered by a Web site to a Web client. The Web site may deliver one or more cookies to the client. The client stores cookie data on its local hard drive. In certain cases (determined by the data in the cookie itself), the client returns the cookie to the server that originally delivered it.
Why are cookies useful?
Cookies allow Web sites to maintain information on a particular user across HTTP connections. The current HTTP protocol is stateless, meaning that the server does not store any information about a particular HTTP transaction; each connection is "fresh" and has no knowledge of any other HTTP transaction. "State" information is information about a communication between a user and a server, similar in many ways to frequent flyer profiles or option settings in desktop software. (For example, a preference for aisle or window seats is cookielike information that a frequent-flyer program might store about one of its customers.) In some cases it is useful to maintain state information about the user across HTTP transactions.