A “cookie” is a small text file, containing a certain amount of information, stored on the browser/device used by a user to view a web page or to use a web-service. This information is retrieved back by the web-server each time the browser/device requires it to serve content. With this retrieved information, the web-server can “recognize” that the user has already visited that page before and has eventually chosen some preferences (such as language selection, units of measure, cookie policy acceptance etc.). In this way, the web-server can provide more relevant and customized content to the user.
Another way cookies are used by web-servers is for tracking the navigation paths that a user follows during his/her visit to the website. This data can be used to profile navigation habits in order to send customized ads, to statistically analyse website’s visits and/or to provide more tailored online services.
Many websites could also make use of “third-party cookies”. These are typically managed by other websites/web-services which content can come from external servers, even though the content itself is viewed in the initial website. Each of these may use their own cookies for the same purposes described above.
Some cookies are necessary for the efficient navigation and are automatically assigned to the visitor; most of them are destroyed after leaving the website (“Session”). Other cookies (“Persistent”) could be kept saved on the browser/device for a longer time; depending on the use they are designed for (i.e. keep track of user’s language preference when he/she visit the website in future).
You can read more about cookies on this Wikipedia article.