Summary
In this chapter, I explained how an application can use cookies to correlate HTTP requests to create a stateful user experience over a stateless protocol:
- Cookies are created by adding the
Set-Cookie
header to responses. - Browers include cookies in requests with the
Cookie
header. - Cookies are configured using cookie attributes, including setting an expiration time, after which the browser will no longer include the cookie in requests.
- Cookies can be signed, which reveals when they have been altered.
- Cookies can be used to store small amounts of data, but this data must then be repeatedly transferred between the browser and the server.
- Cookies can also be used to store session IDs, which are used to load data stored by the server. This makes the server more complicated but means that only the ID is transferred between the browser and the server.
In the next chapter, I will describe how RESTful web services can be used to provide...