A cookie is a small file with some data in it (like username and password) , stored on the client computer or browser by the web server. This data is labeled with an ID unique to client and clients's computer. When the cookie is exchanged between client computer and the network server, the server reads the ID and knows what information to specifically serve to client. A cookie can only be read from the domain that it has been issued from. For example, a cookie set using the domain anonsagar.com cannot be read from any other domain.
Cookie allows us to track the state of the application using small files stored on the user’s computer.It helps to improve the users web experiences.For example: Without cookies you need to re-login to the particular website each next time when you visit there. Infact cookie is also used to store the data like ,by allowing user to select preference.And the next time when the user visit the site, the site will show the data according to user's selected preference with the help of data stored in cookies.