A cookie is a small piece of data that a website asks a web browser to store on a user’s computer or other device.
HTTP cookies help websites remember information across otherwise separate requests. They can preserve a shopping cart, keep a user signed in, remember language or display preferences, or associate a browser with a session. When the browser later contacts the same site, it can send the relevant cookie back in an HTTP request.
The idea originated in 1994, when Netscape programmer Lou Montulli adapted the older computing concept of a “magic cookie” to help support online shopping carts. Cookies usually contain a name and value, along with attributes such as an expiration time, domain, Secure flag, or HttpOnly flag.
A cookie is not the same as browser history, cache, or a login token, although it may contain a session identifier used for authentication. Session cookies generally expire when the browser closes, while persistent cookies remain until their expiration date or deletion.