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?
- PHP | Cookies
- ES6 | Cookies
- How cookies are used in a website?
- Express.js req.cookies Property
- How to set and unset cookies using jQuery?
- HTTP Cookies in Node.js
- How to get cookies from curl into a variable in PHP ?
- If we delete cookies of a site, we can still logged in without logging again
- Express Cookie-Parser - Signed and Unsigned Cookies
- p5.js | clear() function
- CSS | clear Property
- D3.js | d3.map.clear() Function
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.