A cookie is a simple text file containing information about a used that is placed on a user's computer by a web server when they visit. The information in the cookie file is retrieved and updated by a server every time the user visits the website to identify and isolate the user's movements. Each cookie is unique to the web browser that was in use when the website was accessed.
Cookies are usually set by the website you are visiting – these are known as 'first party cookies'. However, cookies can also be set by other websites that have published the content on the page you are viewing – these are known as third party cookies.
The main point of cookies is to improve the experience of visiting a website. If the server knows a little bit of information about the user from previous sessions, a more tailored experience can be served to that user. For example, if you complete an online shopping order, the service will be able to know the products that you usually put in your basket from the information in your cookie file.
Cookies also enable advertisers to target ads and marketing messages more effectively based on what they know about the user from their cookie file, such as location and whether or not they have purchased anything from the site before. Cookies are also used to split users in an A/B test, so individuals will be served the same version of the page on every session.