Visit Paul's websites:
From Computing to Computational Thinking (computize.org)
Becoming a Computational Thinker: Success in the Digital Age (computize.org/CTer)
We all love cookies, sweet and tasty! But here, we are talking about a different kind of cookie–the cookies used by websites and browsers (Figure 1). Such cookies are stored data to make your web surfing easier, more effective and efficient. Cookies are basically unavoidable for anyone who goes online. Therefore, we all need to face dealing with them head-on.
We’ll look at web cookies, what they are, why they are needed, and what pitfalls they may bring. With such understanding, we can better deal with cookies and manage permissions to their use in different situations.
This article is part of our Computational Thinking (CT) blog. You can find other interesting articles in aroundKent (aroundkent.net), an online magazine. You can also find many such articles in the author’s book Becoming A Computational Thinker: Success in the Digital Age. See the website computize.org/CTer for more information.
Let’s begin by looking at the web, how it works and why it needs cookies.
The web is formed by many web servers on the Internet. They offer various services online, including news, shopping, banking, entertainment, learning, healthcare, social media, and many more. Indeed, modern living depends on the web.
We, the users, use a client app to obtain the contents provided by the servers. A client app is usually a web browser such as Google Chrome, Firefox, MS Edge, and Apple Safari. Of course, this follows the typical Internet client-and-server communication model (Figure 2).
A web client communicates with any web server through a specific protocol, namely the Hypertext Transfer Protocol (HTTP)1. Here is a way to visualize client-server interactions via HTTP:
In other words, an HTTP request is like a letter sent to the server and the HTTP response is like a reply letter. After the response, the server is not required to remember the request or response and usually forgets it entirely. Thus, for HTTP, every request-response pair is self-contained and independent of any other. This property is described as the stateless nature of the HTTP protocol.
The HTTP being stateless makes it easy for web servers to become efficient, scalable and robust, among other advantages. HTTP remains stateless to this day.
However, the statelessness does present a serious shortcoming, namely a way is needed to connect related client requests. When calling customer service, do you get annoyed when the other end keeps asking you to repeat the same information after being transferred? To further illustrate this, let’s visualize an imagined stateless pizza store.
You, the client, call the pizza store and order a hand-tossed pizza. The pizza place replies with an “order received” message, and ends the call. So far so good. Now, you want to add some pepperoni topping. So, you call again sending another request. But the stateless store has no way to know which pizza order needs the topping! Now that would be very frustrating indeed.
Sure, you can order the pizza with the topping in the first place. But what if latter you wish to cancel the order or change the pick-up time? The fact is, some business requires more than one request-response step between the client and the server.
Like in the famous movie Memento (Figure 3), websites all have serious memory loss problem and a way must be found to fix that. The remedy is cookies!
A cookie is a piece of data that a web server asks a client (browser) to store (save) in the memory on your computing device. A copy of the cookie (data) is automatically sent back to the same server with every future request. Imagine that the stateless pizza store can tell you, the client, to remember an order number for example. You would present this order number (cookie) in any future request. Obviously, this solves the problem we discussed earlier.
A web server uses the HTTP Set-Cookie header in its response to save cookie data on the client side. Cookie data are usually in the form of one or more attribute=value pairs, order=123456 for example.
A cookie undergoes the following lifecycle: created by the website, stored in the browser, ready to be automatically sent to the same server upon later visits via the Cookie HTTP header, removed or expired at the end (Figure 4).
The cookie was invented by Lou Montulli, a programmer at Netscape Communications, in 19942. And the use of cookies basically solved the problem of remembering user-specific data for subsequent requests (webpage visits).
Thus, a website can use cookies to connect earlier steps to later ones for users in multi-step procedures as well as certain other situations.
Here’s a list of common cookie uses, explained in simple terms with clear examples to help everyone see how cookies make the web more functional and convenient.
These examples illustrate the broad range of ways cookies enhance our online experiences in everyday life. And we see how cookies make the web more convenient by remembering our actions, preferences, and data. While they’re incredibly useful, understanding their purpose helps users make better choices about accepting or rejecting cookies.
Cookies are used by websites in many ways, including shopping carts, authentication (login session), personal preferences (remembering themes/layouts), analytics (tracking user behavior across a site or multiple visits), advertising (targeting ads based on browsing behavior).
Functional cookies are critical for the website to work and they typically do not require user consent as they provide critical functionality. Other cookies, such as analytics cookies, advertising cookies, and tracking cookies, are not essential for functionality but often used for marketing, user behavior tracking, or improving website performance. These usually require explicit user consent due to privacy and security concerns. By limiting permissions, users can minimize unnecessary data collection and potential misuse of their information.
Different countries and regions have laws and regulations on how websites use cookies. These laws include:
Many other countries also have similar cookie laws.
Basically, cookie laws require websites to obtain consent from users, before using their cookies. Websites must also record consent and provide proof of it, display a cookie banner (Figure 6) on the user’s first visit, clearly state what action will grant consent, link to a cookie policy, create and publish a privacy policy.
Here are some simple rules for users to deal with cookie banners effectively and protect their privacy while maintaining a functional web experience:
By following these rules, users can manage cookie banners effectively, minimize unnecessary tracking, and strike a balance between privacy and functionality. Taking small, consistent actions to control cookies can significantly enhance your online privacy.
It is interesting to note that a website remembers your cookie permissions by using cookies.
The stateless nature of the HTTP(S) protocol makes the web efficient and robust. At the same time, it makes remembering important data and in-
formation across visits difficult. Web cookies have become an effective and widely used solution. You can say that the cookie mechanism is a necessary evil for the web.
Yet, unchecked use of cookies can present privacy and security concerns prompting many countries and regions to enact laws and regulations that require websites to obtain explicit user consent for the nonessential use of cookies. Note that these regulations do not apply to cookies created by browsers on their own initiative.
Dealing with cookies and permissions makes life online more complicated. It highlights the need for computational thinking (CT) to become common sense in the digital age. The idea that CT is literacy will soon become more obvious to everyone.
Finally, why cookies?! Most think the term originates from the computer programming concept of a “magic cookie,” which refers to a small piece of data that a program receives and sends back unchanged, essentially acting like a unique identifier. Imagine a program becoming hungry for a cookie and wants it badly like the cookie monster (Figure 7) in the PBS kids show Sesame Street.
1 Many modern websites use HTTPS which is HTTP with secure data transport.
2The Netscape Navigator is the predecessor to Firefox.
ABOUT PAUL
A Ph.D. and faculty member from MIT, Paul Wang (王 士 弘) became a Computer Science professor (Kent State University) in 1981, and served as a Director at the Institute for Computational Mathematics at Kent from 1986 to 2011. He retired in 2012 and is now professor emeritus at Kent State University.
Paul is a leading expert in Symbolic and Algebraic Computation (SAC). He has conducted over forty research projects funded by government and industry, authored many well-regarded Computer Science textbooks, most also translated into foreign languages, and released many software tools. He received the Ohio Governor's Award for University Faculty Entrepreneurship (2001). Paul supervised 14 Ph.D. and over 26 Master-degree students.
His Ph.D. dissertation, advised by Joel Moses, was on Evaluation of Definite Integrals by Symbolic Manipulation. Paul's main research interests include Symbolic and Algebraic Computation (SAC), polynomial factoring and GCD algorithms, automatic code generation, Internet Accessible Mathematical Computation (IAMC), enabling technologies for and classroom delivery of Web-based Mathematics Education (WME), as well as parallel and distributed SAC. Paul has made significant contributions to many parts of the MAXIMA computer algebra system. See these online demos for an experience with MAXIMA.
Paul continues to work jointly with others nationally and internationally in computer science teaching and research, write textbooks, IT consult as sofpower.com, and manage his Web development business webtong.com