Cookies are data, stored in small text files, in your browser.
When a web server sends a web page to a browser, the connection gets closed and so the server forgets everything about the user.
Cookies were invented to solve this problem about remembering the user.
When a user visits a web page, the user's name can be stored in a cookie.
Next time the user visits the page, the cookie is a token that can remember and identify the user.
Cookies are saved in key-value pairs like this
Name = Johnny Appleseed
When a browser requests a web page from a server, cookies belonging to the page are added to the HTTP request. Thus the server will have the necessary data about users.