This document compares cookies and sessions for maintaining state in web applications. Cookies are small pieces of text stored on a user's browser that can be used to link pages together during a user's session. Sessions instead store changing information on the server side using a unique session ID passed from the client on each request. The document outlines how sessions work in servlets through the HttpSession interface to store and retrieve attributes across requests.