Report post

What is document Cookie?

What is document.cookie? I’ve used cookies as a web developer for many years, but never understood them in detail. In this post, I look at the document.cookie API. Cookies are client-side storage. Cookies were the first client-side storage available in the browser. They have three main use-cases: sessions, preferences, and tracking.

What are cookie attributes?

Two cookie attributes determine whether the cookie is used: the cookie’s domain and the cookie’s path . Together, the domain and path are called the cookie’s “scope”. For the Google Analytics cookies, the domain value is .jameshfisher.com , and the path value is / .

How do I access cookies?

For accessing cookies, the document.cookie property is used. Small and convenient methods, such as getCookie (name), setCookie (name, value, options), and deleteCookie (name) are used to make working with cookies more efficient. The secure and samesite options are used for making it safer to work with cookies.

How do cookies work?

Cookies are small data strings, stored directly in the browser. They are included in the HTTP protocol. As a rule, the web-server sets cookies with the help of a response Set-Cookie HTTP header. After that, the browser adds them to each request to the same domain, using the Cookie HTTP header.

Related articles

The World's Leading Crypto Trading Platform

Get my welcome gifts