Their requests for web pages look like any other visitor's requests for web pages. Imagine that you're writing a shopping cart program that allows users to add items to the shopping cart from any page on the web site. There may be several users shopping on the site at the same time, all of them with their own shopping carts. Each time the person visits a page on the shopping site, the browser sends the ID so that the shopping cart can know which shopping cart to add items to. Cookies can be used in other useful ways.
Some sites require a username and password to log in to a member's area.
By setting a cookie, the sites can speed your login. When your browser sends the cookie containing the user ID, the site can bypass the username and password step, because it recognizes you as a registered user. Note that this does not mean the username and password are stored in the cookie. Instead, the user ID is essentially used as a substitute for the username and password. One of the newsgroups I read has been embroiled in a debate over cookies this past week.