Computer Networks · TEE · papers

Q7(b) · HTTP cookies

2022-11-16 · AI-only Sem V

Exact historical variant. Current-syllabus questions solved; excluded topics and source limitations stated.

Q7(b). An e-commerce site wants to keep a purchase record for each customer. Illustrate how cookies can do this. [5 marks]

Answer

ConceptExplanationExample
GETRetrieve the selected representationRead a page
POSTAsk the resource to process submitted contentSubmit a form
PUT / DELETEReplace target representation / request removal according to server semanticsUpdate/delete an API resource
200 / 301 / 404 / 500Success / permanent redirect / not found / server errorRead status before interpreting body
Persistent connectionReuse a connection for multiple exchangesAvoid repeated TCP setup for each image
Cookie/session tokenCarry an identifier so the application can relate requestsRemain signed in
HTTPSHTTP protected by authenticated encryption through TLS in common deploymentsProtect credentials and content in transit

A secure transport protects the connection; it does not prove that every server’s content is truthful. HTTP method semantics and application authorization still matter. For exam comparisons, separate HTTP semantics, connection lifetime and application session state.

First visit→Server creates customer/session ID→Set-Cookie header→Browser stores cookie→Later Cookie header→Server retrieves purchase record

Keep the purchase record in the server database keyed by a suitable identifier; the browser need only carry that identifier. Example: cookie customer=R81 links later visits to R81’s stored orders. HTTP requests remain independent at the protocol level; the application supplies continuity. Account login can restore the record when a cookie is absent.