WWW Basics and Cookies Explained: URL Flow, Cookie Scope and Exam Traps

Trace a complete shop.example page load, then decide which cookies survive host, path, security and expiry checks across five requests. The examples turn common WWW traps into a repeatable exam method.

KnowledgeGate Team

Exam prep & CS education

Updated 31 Oct 20265 min read
WWW Basics and Cookies Explained: URL Flow, Cookie Scope and Exam Traps

You use a browser every day, yet one exam question can make the Internet, the Web, a website, a URL, HTTP and a cookie sound like the same thing. They are not. A shop.example page can be traced from URL to response, and the resulting values can be tested in a five-request cookie table. RFC 3986 defines URI syntax, RFC 9110 defines HTTP semantics and RFC 6265 defines cookie behavior.

1. Build the WWW Mental Model Before Memorising Terms

The Internet is a network of networks. The World Wide Web is a system of linked resources accessed by clients and servers through HTTP or HTTPS.

Here, shop.example is the website, /prefs/view is a page and /assets/logo.png is a separate resource. The browser is the client; the web server answers it. DNS resolves the host name, lower layers carry data, HTTP gives request-response semantics, HTML describes the document and hyperlinks connect resources. Application Layer Protocols: DNS and HTTP compares DNS and HTTP across the wider application layer. In the running example, the URL and resource count become inputs to the cookie-scope trace.

A browser retrieves resources; a search engine discovers them. The Web is one application system carried by the Internet, not the whole Internet.

2. Decode One URL and Trace a Three-Resource Page Load

Consider this URL:

https://shop.example:443/prefs/view?mode=compact#tips

Its components are:

Component

Value

Scheme

https

Host

shop.example

Explicit port

443

Path

/prefs/view

Query

mode=compact

Fragment

tips

RFC 3986 defines this generic URI structure. Under RFC 9110, the HTTP request target is /prefs/view?mode=compact; client-side #tips is excluded. See the RFC Editor.

Now assume a cold, uncached load. DNS maps shop.example to the documentation address 192.0.2.25. The browser connects securely to 192.0.2.25:443 and sends:

http
GET /prefs/view?mode=compact HTTP/1.1
Host: shop.example

The server returns 200 OK with 12 KiB of HTML, which references /assets/logo.png of 4 KiB and /assets/site.css of 8 KiB.

  • HTTP requests: 1 + 2 = 3

  • HTTP responses: 3

  • Payload downloaded: 12 + 4 + 8 = 24 KiB

This calculation excludes headers, compression, cache hits, redirects and retransmissions. For message syntax, status codes, caching and RTT calculations, use HTTP Protocol Explained: Requests, Caching, RTT Examples and Exam Traps. Here, resource counting identifies the requests that may carry cookies.

Sequence diagram of the shop.example page load: DNS lookup, GET /prefs/view, then logo.png and site.css, totalling 3 requests and 24 KiB.

3. Why Cookies Exist on Top of Stateless HTTP

HTTP does not by itself remember a previous request, but applications need continuity for a login, language choice or cart. Under RFC 6265, a server sends a name-value pair in Set-Cookie; the user agent returns stored pairs in Cookie on qualifying requests.

Here, sid=A7F9 is an opaque key for server-side session state, not necessarily personal data. theme=dark stores a preference.

A cookie is client-held state sent with matching requests. A session is application state, often keyed by a cookie. A cache stores reusable representations. Cookies add continuity to the DNS and HTTP path; they do not change DNS, transport or routing.

At exactly 10:00:00, https://shop.example/login returns:

http
Set-Cookie: sid=A7F9; Path=/; Max-Age=1800; Secure; HttpOnly
Set-Cookie: theme=dark; Path=/prefs; Max-Age=86400

Neither header has Domain, so both cookies are host-only for shop.example under RFC 6265:

  • 1800 seconds / 60 = 30 minutes, so sid expires at 10:30:00.

  • 86400 seconds / 3600 = 24 hours, so theme expires at 10:00:00 the next day.

Test host, path, secure-channel requirement and expiry for each request:

Time

Request URL

sid eligible?

theme eligible?

Cookie pairs sent

Reason

A, 10:10

https://shop.example/prefs/view

Yes

Yes

{sid=A7F9, theme=dark}

All checks pass for both cookies.

B, 10:20

https://shop.example/cart

Yes

No

{sid=A7F9}

/prefs does not path-match /cart.

C, 10:20

http://shop.example/prefs/view

No

Yes

{theme=dark}

Secure blocks sid; theme lacks that attribute.

D, 10:20

https://cdn.shop.example/prefs/view

No

No

{}

Host-only cookies for shop.example do not match the subdomain.

E, 10:31

https://shop.example/prefs/view

No

Yes

{theme=dark}

sid expired at 10:30:00; theme remains valid.

Do not assume pair ordering in A. sid is sent in A and B, so 2 times. theme is sent in A, C and E, so 3 times. Total name-value transmissions are 2 + 3 = 5. Requests A, B, C and E carry cookies, which is 4 of 5 requests.

Cookie request table fixes D at 10:20: expiry, path, and HTTPS pass; host-only cookies still send no pairs.

Idea

What it controls

Running-example effect

Host-only versus Domain

Which host names qualify

No Domain allows shop.example, not cdn.shop.example.

Path

Which request paths qualify

/ covers both shown paths; /prefs covers /prefs/view, not /cart.

Max-Age or Expires

Persistent lifetime

1800 means 30 minutes; 86400 means 24 hours.

Secure

Whether sending requires a secure channel

sid is blocked on http; theme is not.

HttpOnly

Access through non-HTTP APIs

Those APIs cannot access sid, but qualifying HTTP requests still send it.

A session cookie has no persistent expiry attribute and lasts for a user-agent-defined session. The example's two persistent cookies use Max-Age. First-party and third-party describe request context; they do not replace host, path, Secure or expiry checks.

Secure restricts sending, not stored-value encryption. HttpOnly restricts script access, not secure transport. Path selects requests, but is not an isolation guarantee. RFC 6265 defines these boundaries; sid=A7F9 is opaque; its meaning does not affect eligibility. Attributes and request context do.

Trap

Correct replacement

The Web and Internet are synonyms.

The Web is one system over Internet infrastructure.

The fragment is sent to the server.

#tips stays client-side here.

One page means one request.

Three resources cause three uncached requests here.

A cookie is a cache entry.

A cookie carries state; a cache reuses a representation.

No Domain includes every subdomain.

Host-only excludes cdn.shop.example.

Path=/prefs matches /cart.

Path matching rejects theme.

Secure blocks every cookie on HTTP.

Request C blocks sid, not theme.

HttpOnly stops network transmission.

It restricts API access, not HTTP sending.

sid is valid at 10:31.

It expired at 10:30:00.

A session cookie must survive browser closure.

The user agent defines its session boundary.

Never decide from one attribute. For each cookie, test host or domain, path, secure-channel requirement and expiry in that order. Count only the pairs that survive all four checks.

7. How Exams Test WWW Basics and Cookies, Then the Next Step

Typical questions match browser, server and URL roles; split URL components; count resources; distinguish cookie, session and cache; or trace Domain, Path, Secure and expiry.

Use this five-step routine:

  1. Parse the URL.

  2. List resources and state the cache assumptions.

  3. Copy every Set-Cookie attribute.

  4. Test each later request against host, path, secure channel and time.

  5. Count requests, responses or cookie pairs exactly as asked.

The Application Layer MCQ collection gives you more than 10 questions on WWW basics and cookies.

The short version

The Web links addressable resources. A URL identifies the request. One page can trigger several requests, and cookies add scoped continuity to stateless semantics.

For core-CS revision, use Computer Science Fundamentals for Placements. The CS Fundamentals category groups the wider subject sequence.