HTTP cookies

An HTTP cookie (such as a web cookie or browser cookie) is a very simple dictionary/key-value store that a server can send to the client. It is sent by the server using the Set-Cookie header. For example, a Set-Cookie header may look like this:

Set-Cookie: <cookie-name>=<cookie-value>; Domain=<domain-value>; Expires=<date>

Multiple Set-Cookie headers can be sent in the same response message to compose the key-value store.

What's special about cookies is the fact that most browser clients will automatically send this key-value store back with each subsequent request, this time inside a Cookie header:

Cookie: name1=value1; name2=value2

Therefore, if we use a cookie to store the user's session ID in the browser, it'll allow the ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.