title: Why does document.cookie exist and when is it used by DOM in a browser?
body: <p>I am a bit confused by the <em>document.cookie</em> property: why does this property exist at all, and under what scenario the DOM, when being rendered in a browser, want to access it?</p>
  <p>The examples that I can find, such as <a href="https://www.w3schools.com/js/js_cookies.asp" rel="nofollow noreferrer">https://www.w3schools.com/js/js_cookies.asp</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie</a>, only tell me how to read or write a cookie, but I wonder <strong>why</strong> the DOM need to access the cookie at all.</p>
  <p>Consider an HTTP response, both the web document and the cookie are sent from the origin server, what is the reason that the web document wants to access the cookie only after it is loaded into the browser? Why can't such jobs be done at the server side and save client's effort and time? And based on my understanding, cookie is used for the server to identify session or user and will be attached by the browser when a request is sent to the server, which does not contain any meaningful content from human being's perspective, so what practical use of cookies in the DOM context?</p>