OK, I will try to explain cookies, but it is not a strong point.
Basically, there are two major families of protocols - TCP and UDP. The TCP family involves establishing a persistent connection between two tasks that use the network. These tasks negotiate what they will do and then use the established session to do it. FTP, SMTP, SMB, ODBC, and several other protocols are in the TCP family.
The UDP family does not depend on establishing connections in the same way. There are "broadcast" UDP messages and "lookup" messages and "routing" messages which tend to be of a non-persistent nature. I.e. you ask for something - say, a name-to-address translation - and get a response, after which you are done with that transaction. For web servers, you always have a client/server (or client/host in some articles) situation.
The client asks the host to "see something" and perhaps provides identifying information. The host validates this to define a user's connection but in the web case does not create a negotiated persistent session. Instead, the host sends identifying session information to the client side that the client then uses to include its ID in subsequent exchanges. The file in which this information is stored is called a "cookie." Cookies have several purposes.
1. Identifying that the client is "known" to the host - a session or identification cookie.
2. Identifying the "stage" of a particular sequence - like a bookmark to show where you are in a a particular sequence. (Think "online survey")
3. Remembering choices you made earlier - a "preferences" cookie
4. Remembering page visits you made earlier - a "previous interest" cookie. (Also used for web pages that ask you to pay for a subscription after x visits)
5. Remembering that you have seen an advertisement - usually 3rd-party "interest" cookies.
6. Anything else the page author can think of.
Cookies have expiration timers when the session represents something important and confidential. Think of a bank account web page that holds information you don't want available for too long, so what happens is that the virtual session expires after a while and thus a careless user who walks away from an improperly closed session won't be compromised by the next person to use that computer.
The "Previous Visit" cookie in banking also works by requiring you to verify that you want to do a bank transaction from a computer that the bank's host has not seen before. But once the bank knows that you trust that computer, it doesn't ask again. Unless you erase cookies that you didn't really want to erase.
So, short answer: A cookie is a file stored on your computer and used by web sites to have YOUR computer help the host site remember what you did, either recently or not so recently, for purposes of security, identification, or advertising revenue.