Cookies are a good way of accomplishing this. In fact, this is so useful that servlets have an API specifically for this, and servlet authors don't need to manipulate cookies directly to make use of it. This is discussed in the tutorial section on Session Tracking . Avoiding username and password. Many large sites require you to register in order to use their services, but it is inconvenient to remember the username and password.
Cookies are a good alternative for low-security sites.
When the client reconnects at a later date, the user ID is returned, the server looks it up, determines it belongs to a registered user, and doesn't require an explicit username and password. Customizing a site. They use cookies to remember what you wanted, so that you get that result initially next time. I'll give an example like this later in this section of the tutorial. The problem is that they have to show a random ad when you first arrive and haven't yet performed a search, as well as when you search on something that doesn't match any ad categories.