Computer Science · Ch 12 — Security Aspects
Cookies
Cookies
What a Cookie Really Is
The word "cookie" comes from the Unix programmers' term magic cookie — a packet of data that a program receives and then sends back unchanged. In the web world, a computer cookie is a small file or data packet that a website stores on the client's computer. The key point is that a cookie can be edited only by the website that created it; the client's computer merely acts as a host to store it.
Websites use cookies to store browsing information about the user. For instance, on an e-commerce website, when you add items to your cart, the site uses cookies to record those items. Cookies can also hold other user-centric information such as login credentials, language preference, search queries, recently viewed web pages, music choice, favourite cuisine, and more. All of this helps enhance the user experience and makes browsing time more productive.
Types of Cookies
Depending on their task, there are different types of cookies:
- Session cookies — These keep track of the current session and terminate the session when there is a time-out. A banking website is a classic example: if you accidentally leave your e-banking page open, it will automatically close after the time-out.
- Authentication cookies — These are used by a website to check whether the user is previously logged in (authenticated) or not. Because of them, you don't need to log in again and again while visiting different web pages or links of the same website.
Auto-fill and Other Everyday Uses
You may have noticed that certain information like your name, address, contact number, date of birth, etc., automatically fills up while you fill an online form. This auto-fill feature is also implemented by websites using cookies.