A cookie or htpp cookie is a small set of strings specially in name value pairs that are stored in the user’s web browser. This string comes from a

What is http cookie and how it works?

submited by
Style Pass
2021-07-26 21:00:08

A cookie or htpp cookie is a small set of strings specially in name value pairs that are stored in the user’s web browser. This string comes from a server and mostly used to identify the clients.

The HTTP protocol is stateless which means that the server does not remember about any response it sent to the user’s browser. It executes each request independently without knowing past requests that are already executed. This is not at all good if a user is accessing secure page like making a financial transaction as server will not identify if the request is coming from a valid customer. To solve such issues, cookie concept was introduced which is fairly easy to understand and implement.

Lets see how cookie can solve the above problem. When a user sign in to a server, the server creates a unique ID and set it as a name value pair cookie with an expiry date or timestamp and sends it to the user’s browser. When the same user make a transaction or access another secure page on the same server, it sends the http cookie along with the request. Upon receiving another request from user, the server extracts and validates the cookie string or ID and its expiry date and allows transaction if its coming from valid signed in user.

As mentioned earlier, a cookie is a name value pair data set by the server. Along with the name value pair, a cookie has optional attributes like expiry date,domain, path and few others. Lets check

Leave a Comment