What are cookies?
Cookies are a standard mechanism that allows a website (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 website. Cookies are a way of storing consistent client data so that a site can maintain information on a user across HTTP connections. ("consistent" means the information from the website lasts longer than the immediate connection.)
How do cookies work?
Cookies are small data structures delivered by a website to a web client. The website 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 websites 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.