What is the relationship between server side cookie and javascript cookie?

I want to know the relationship between cookies created by the Cookie Class in Servlet and document.cookie in JS.

+5
source share
1 answer

document.cookie is a very odd property:

  • If you read its value, it gives you all the cookies that the browser stores that relate to the document as one massive line. This is not ... all that is useful for the format. It gives only the name and value of the cookie, and not additional information about the cookie, like the path to which it refers or when it expires. This is basically a semicolon list of name = value elements.

  • If you write your value, it adds or updates the cookie for the document in the browser. Subsequent server requests will contain this optional / updated cookie.

Thus, the connection is that it provides JavaScript access to cookie data related to this document, which may have come from the server or may have been added by JavaScript.

+6
source

All Articles