Cookies provide a way for a client and server to interact and pass information via HTTP. This enables the client to store state information despite using HTTP which is a stateless protocol. When a browser requests a web page from a server, the server services the request and “forgets” about the visit. But it passes some information to the user’s browser. The browser stores the information in the form of key=value pairs and also manages this information.
- Cookie information is passed in the HTTP request header during every subsequent visit to the domain from the user’s browser.
- Information like login details, consent, other preferences are used to enhance and customize the user experience.
HTTP cookies expire, the date and time are specified in the “expires” attribute. As a result, the browser automatically deletes the cookies when the date and time exceed the expiration date (and time). As this attribute is configurable*, it is possible to delete all the cookies by setting the “expiry” to any value that has already passed.
The cookie property of the current document is used to modify the attributes of the cookies buy using HTML DOM cookie Property. The document.cookie returns a single string of all the cookies separated by semicolons associated with the current document.
document.cookie = "key=value";
- How to set, get and clear cookies in AngularJs?
- How to set and unset cookies using jQuery?
- How cookies are used in a website?
- HTTP Cookies in Node.js
- PHP | Cookies
- Express Cookie-Parser - Signed and Unsigned Cookies
- If we delete cookies of a site, we can still logged in without logging again
- How to get cookies from curl into a variable in PHP ?
- ES6 | Cookies
- Express.js req.cookies Property
- How to clear all options in a dropdown box?
- How to clear all div's content inside a parent div ?
- How to clear the canvas using clearRect in HTML ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.