Javatpoint Logo
Javatpoint Logo

Cookie Definition

Cookies are sets of information from one webpage that are preserved in a browser window for later retrieval by that website. Thanks to cookies, the server might be informed when users have visited a specific website again. A cookie gives information and lets the website display customized settings and tailored content when users return.

Moreover, cookies save information on user preferences, the items in their shopping cart, and their log-in or registration details. This is done to make it simple for visitors to retrieve any data they previously submitted or preferences they previously specified when they visit a site again. Cookies help advertisers track user behaviour across websites to target their adverts. Some people consider this approach to be intrusive, even though it is typically used to give users a better customized user experience.

Cookie Definition


Magic cookies were already in use when computer programmer "Lou Montulli" had the idea to use them in web communications in June 1994. At the time, he was employed by Netscape Communications, which was developing an online store for MCI. When MCI and Netscape Communications had technical negotiations, Vint Cerf & John Klensin represented MCI. MCI asked Netscape to discover a mechanism to store that information in each user's machine since they did not want to have to keep track of partial transaction states on their servers. A solution was offered via cookies to build a virtual shopping cart reliably.

The official cookie specifications had previously been created. On the www-talk email list, the first discussions for a formal specification began in April 1995A the "Internet Engineering Task Force (IETF)" created special working group. Brian Behlendorf & David Kristol had each put out a different suggestion for adding state to HTTP transactions. But, the group, led by Lou Montulli and Kristol himself, quickly started with the Netscape standard. The working group recognised third-party cookies as a serious privacy risk in February 1996. The group's specification was eventually released as RFC 2109 in February 1997. It states that third-party cookies either were completely prohibited or at the very least, not turned on by default. Advertising businesses were already utilising third-party cookies at this time. Netscape & Internet Explorer did not abide by RFC 2109's advice about third-party cookies. In October 2000, RFC 2965 replaced RFC 2109 as the standard.

Storage of a Cookie

Web browsers keep cookies in a specific file on users' devices. All cookies are kept in a file called "Cookies" by the web browser, Google Chrome, for example. By accessing the developer tools, selecting the "Application" tab, & selecting "Cookies" from the left-side menu, Chrome users can inspect the cookies that the browser has saved.

Types of Cookies

Session cookies

Transient cookies and per-session cookies are other names for session cookies. As a person is browsing a website, session cookies save data. These cookies are deleted if the user closes their browser session.

Persistent cookie

Cookies that are persistent are kept for a predetermined period of time. Until they are erased or expire, these cookies stay on your device. Due to their usage in gathering user data, like browsing preferences and behaviors, persistent cookies are often referred to as tracking cookies.

Cookies from both first- and third-parties

Cookies that are first-party are the ones that are made by the sites that people access directly. These cookies frequently hold data that is pertinent to or associated with the website, including user preferences or location. Cookies that are associated with third-party resources, such as embedded videos, advertisements, web banners, and scripts, are referred to as third-party cookies. Advertisers frequently use third-party cookies to monitor user behaviour.

Cookie Definition

Super cookie

In the same way, as session cookies track user behavior and browsing history, supercookies do the same. Even if regular cookies are deleted, new user profiles can still be created using them. Moreover, supercookies are kept in distinct locations than regular cookies. This makes it more difficult for the average user to locate and get rid of them. Supercookies are also called "ever cookies" or "zombie cookies."

Quick cookie

Websites that make use of Adobe Flash may store data files known as "Flash cookies" or "local shared objects" (LSOs) on users' computers. Flash cookies allow users' information to be stored in Flash programs like browser cookies. Sites occasionally use Flash cookies as "backup" after deleting the browser cookie.

Uses of Cookies

Session management

As users browse a website, cookies were first introduced to give them the means to keep track of the products they want to buy (a virtual shopping cart or shopping basket). Today, however, a user's shopping cart's contents are often saved in a server database instead of a client cookie. To track which user is associated with which shopping cart, the server sends the client a cookie with a unique session identity. Although cookies are transmitted to the server with each session the client performs, the session identifier will be transmitted back to it each time a user sees a new page on the website. This instructs the server which shopping cart the user should see.

Cookies are also frequently used to log into websites. A cookie with a specific session identifier is normally sent to the client by the web server whenever a user accesses the login page of a website. The user is given access to the server's services after successfully logging in, and the server keeps track of the fact that that specific session identification has been authenticated.

The amount of personal information a website can save about each user is almost endless because session cookies simply include a specific session identifier; cookie size limitations do not constrain the website. As a session cookie only contains a small amount of information and uses a minimal amount of bandwidth, they also aid in speeding up page loads.


Personalization can be used to keep track of user data so that they can be shown content that is appropriate to them over time. As an illustration, a web server may deliver a cookie comprising the username that was most recently used for logging in to a website, allowing it to be automatically filled up the following time the user checks in.

Many websites personalize content based on the preferences of the user using cookies. The choices made by users are entered into a web form before being sent to the server. The preferences are stored in a cookie that the server delivers to the web browser. In this manner, the server may tailor each website page to the user's request whenever they access it. For instance, the search engine operated by Google employed cookies in the past to let users (including those who weren't registered) choose how many query outcomes they wished to see per page. Moreover, DuckDuckGo uses cookies to let users customize viewing preferences, including web page colours.


Users' online browsing behaviours are tracked via tracking cookies. The referrer field in the HTTP request header or the IP address of the system making the request can also be used to some extent for this, but cookies offer higher accuracy. As an example, consider the following:

The server assumes this is the user's first visit if the user requests a page from the site but the request doesn't include a cookie. To do this, the server creates a unique ID (often a string of random numbers and letters) and sends it, together with the search request, back to the browser as a cookie.

From this point forward, the browser will automatically send the cookie to the server every time a new site from the website being requested. In addition to sending the page as usual, the server also logs the cookie, the date/time the request was made, and the URL of the search request.

It is then feasible to determine which pages the user has viewed, in what order, and for how long by looking at this log file. Companies take advantage of users' online behaviours by tracking cookies to get data on consumer behaviour. The top fifty websites in America, according to The Wall Street Journal, installed an average of 64 pieces of monitoring software on computers, totalling 3,180 tracking files. The information can then be gathered and sold to businesses that will make offers.

Cookie Definition


It is possible for a web browser to send a cookie to a web server hosting a web page and the browser to send the cookie back when accessing another page. Cookies are random data snippets that are typically selected and provided by the web server before being saved on the client's computer by the internet browser. Following that, the browser will send them to the server with each request, providing states to other stateless HTTP interactions. Without cookies, each time a web page or one of its components is retrieved, it does so independently of any previous page views the user has performed on the website. Despite the fact that the web server usually creates cookies, they can also be created by the client using a programming language like JavaScript.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA