First let's start by clearing up exactly what cookies are and what they do.
Cookies are small text files placed on the client machine by the host to store information.
There are a wide variety of things you can do with cookies. On one of the stock market related websites I work with, we use cookies to store personalized info based on the users preferences. Basically what the cookie does is it specifies who the user is, what stocks they have in their portfolio, and a variety of other data. This information isn't stored directly in the cookie, but instead the cookie points to the appropriate place in the database to retrieve the data. So anyways, on to the code.