Understanding Cookies

Duration: 7 min

This video lesson is available to enrolled students.

Enroll to watch — ISRO Scientist/Engineer 'SC'

AI Summary

An AI-generated summary of this video lecture.

This educational video provides a comprehensive introduction to HTTP cookies within the context of web development. The lecture begins by establishing the historical context of the World Wide Web, describing it as originally designed as a "stateless entity" where client-server interactions were transient. The instructor explains that while this design suited early document retrieval, it is insufficient for modern web applications like e-commerce and user portals. The second half of the lecture details the technical architecture of cookies, explaining the "Creation and Storage of Cookies" and the "Using Cookies" process. It covers how servers store client data, how browsers manage cookie directories, and how cookies facilitate the identification of returning users to maintain session state across multiple requests.

Chapters

  1. 0:00 2:00 00:00-02:00

    The session opens with a slide titled "Cookies," immediately defining the World Wide Web as originally designed as a "stateless entity." The instructor reads from the slide, stating, "A client sends a request; a server responds. Their relationship is over." He explains that this original design of WWW, retrieving publicly available documents, exactly fits this purpose. However, he notes that "Today the Web has other functions; some are listed here." He points to the first bullet point, "Some websites need to allow access to registered clients only," indicating that the stateless nature prevents websites from remembering who a user is without a mechanism like cookies.

  2. 2:00 5:00 02:00-05:00

    The instructor continues to analyze the slide's list of modern web functions that require state retention. He specifically highlights the bullet point: "Websites are being used as electronic stores that allow users to browse through the store, select wanted items, put them in an electronic cart, and pay at the end with a credit card." He explains that without cookies, the server would not know which items a user has selected for their cart. He also discusses portals where "the user selects the Web pages he wants to see" and sites that are "just advertising." He emphasizes that the original design does not fit these purposes, creating a need for a mechanism to store information about the client between requests.

  3. 5:00 7:19 05:00-07:19

    The slide changes to explain the solution: "For these purposes, the cookie mechanism was devised." The instructor details the "Creation and Storage of Cookies," noting that when a server receives a request, it stores information about the client in a file or string. This information may include the "domain name of the client, the contents of the cookie... a timestamp, and other information depending on the implementation." He explains that the server includes the cookie in the response, and the browser stores it in a cookie directory sorted by the domain server name. Finally, he describes "Using Cookies," where the browser looks in the cookie directory to see if it can find a cookie sent by that server. If found, the cookie is included in the request, allowing the server to know "this is an old client, not a new one." The slide concludes with a note that the contents of the cookie are never read by the browser or disclosed to the user, stating it is "a cookie made by the server and eaten by the server."

The lecture effectively bridges the gap between the theoretical limitations of the stateless web and the practical implementation of cookies. It moves from identifying the problem—modern web functions like shopping carts and user portals requiring state retention—to explaining the solution. The technical explanation clarifies the lifecycle of a cookie, from server-side creation and browser-side storage to the retrieval process that enables session continuity.