An HTTP cookie is a small piece of data a server sends to the browser in the Set-Cookie response header. The browser stores it and automatically attaches it to later requests to the same site, helping HTTP "remember" the user.
HTTP itself is stateless: every request is independent. Cookies solve this. In response to the first request the server adds a Set-Cookie header with a value, and the browser saves it and returns it in the Cookie header on every following request to that URL — whether it is a GET for a page or a form submission. This is how sessions, authentication and shopping carts are kept.
Cookies have attributes that control their scope and protection:
Lifetime (Expires or Max-Age) and scope (Domain, Path) are set as well. Cookies power sessions, authentication and analytics — but because of tracking they are subject to privacy rules.