Cookies is the term used to describe a type of message that is given to a web browser by a web server. Its main purpose is to identify users and prepare customized web pages or to save site login information for you.
When someone enters a website using cookies, they will be asked to fill out a form providing personal information; like name, email address, and interests. This information is packaged into a cookie and sent to the web browser, which then stores the information for later use. The next time the user go to the same website, their browser will send the cookie to the web server. The message is then sent back to the server each time the browser requests a page from the server.
A web server has no memory so the hosted website the user is visiting transfers a cookie file of the browser on their computer’s hard disk so that the site can remember who they were and their preferences. This exchange of messages allows the web server to use this information to present the users with customized web pages. For example, instead of seeing just a generic welcome page, the user might see a welcome page with their name on it.
The purpose of the computer cookie is to help the website keep track of user’s visits and activity. This isn’t always a bad thing. For example, many online retailers use cookies to keep track of the items in a user’s shopping cart as they explore the site. Without cookies, your shopping cart would reset to zero every time they clicked a new link on the site. That would make it difficult to buy anything online.
A website might also use cookies to keep a record of user’s most recent visit or to record their login information. Many people find this useful so that they can store passwords on frequently used sites, or simply so they know what they have visited or downloaded in the past.
Types of Cookies
Session Cookie
Also called a transient cookie, it is a cookie that is erased when users close the web browser. It is stored in temporary memory and is not retained after the browser is closed. Session cookies do not collect information from the user’s computer. They typically store information in the form of a session identification that does not personally identify the user
persistent cookie
Also called a permanent cookie, or a stored cookie. It is stored on user’s hard drive until it expires (persistent cookies are set with expiration dates) or until they delete the cookie. These cookies are used to collect identifying information about the user, such as web surfing behavior or user preferences for a specific web site.
Sources:
https://us.norton.com/internetsecurity-privacy-what-are-cookies.html
https://www.webopedia.com/insights/all-about-cookies/
https://computer.howstuffworks.com/internet/basics/question82.htm