Hi Sachin,
Welcome to JavaRanch!!!
Few examples how I understood cookies..
example 1. Problem statement: an online shopping cart, say you added 5 items in the basket but you did not buy them. Tomorrow when you come back and continue shopping your old basket with 5 selected items is required. There are couple of solutions for this problem
i. Save all the selected items in the DB and retrieve when you re-login
ii. Save all this content in the cookie in form of text and make it readily available
Say for something like this which is not the data I should secure, I would rather share the responsibility of this request at both the client and the server. I save the data in cookie and retrieve whenever required. I use session when the state should be only maintained until the user quits the current session. Additionally, the cookie can be disabled from the client end, but the server needs some information that needs to be transferred or retrieved like when cookie is available, so show to proceed? There comes the URL rewriting.
Commercial sites/forums etc.. which doesn't require much of information security uses cookies for storing user authentication data as well.
example 2. Few search engines and few other sites use cookies for better/intelligent marketing purpose. Like if I search for search for online cameras, this information can be stored in cookie and next time when I am searching something else, I recieve ads related to cameras since that is one of my interest. Well this good for me since its like a short cut for me, its good for the provider since makes some good business
example 3. The best one I experienced. Few months back I booked a bus ticket online (it doesn't have any login). Last week I again opened the same site for booking tickets, the source and destination are pre-populated. Then I looked into the cookie and got the picture,
it made my job easier though