Is cookie part of the header of a http request/response? Is it a key value pair? How different is it than Accept or Content-type header keys? [duplicate]

StackOverflow https://stackoverflow.com/questions/19897650

Question

What is the difference between an http header and a cookie? I'm learning Jsps and Servlets. I am not understanding how a cookie is different than other header attributes..

For example: An http request would contain a list of header key-values. One of the header keys is a cookie. Just like connection: Keep-Alive or accept-language: en-us

Correct?

Was it helpful?

Solution

The primary purpose a cookie serves is to persist a small amount of state, remember that HTTP is stateless, in the browser without requiring that the data be re-added to every form request. For an explicit, real world example, consider why one would use URL Rewriting instead of (or in addition) to a session tracking cookie.

OTHER TIPS

Cookies are like temporary storage of data on client side. browser put cookies in his temp directory and send these with each request .

But headers are hints to browser and server . to prepare himself . like content type header it tells that the request is sending data of that particular type like application/json will send json data now server will decide whether it can handle this(type) or not if it can not it will rise exception.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top