Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


What is a cookie?

Educative Answers Team

The Hypertext Transfer Protocol (HTTP) is a stateless protocol, i.e., each request must contain all the required information to fulfill the request. The server does not maintain information from prior client requests. However, this is not how the HTTP that we know today works. If it did, then usernames and passwords would have to be shared every time an HTTP request was sent to a website that required authentication.

A cookie is a key-value pair. It is stored on users’ computers by websites to remember notable information. The cookie is shared with the website that ​set it every time the user visits that website. It is important to note that cookies may have an expiration date.

The illustration below shows how a cookie is set and shared:

Alice visits ebay. ebay's server contains an entry for Alice with ID 8890, Alice's browser saves the cookie.
1 of 3


Some of the most important uses of a cookie are:

  • Storing the contents of users’ shopping carts at online shops.

  • Remembering user preferences on a website to provide a personalized experience for​ each user.


Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring