Now, modern day websites have many functionality, such as authentication, authorization and so on,
and by having these websites will then provide us with what we need so that we can do almost everything
online.
Now, they can also follow you remember, your choices preferences seems convenient, but it goes well
beyond just this.
So the question is.
How do they accomplish it?
So that means that we can look at the HTP more closely in order to understand how Web applications manage
all this.
So, as you know, HDP is a connection, this client server protocol where the server and the client
exchange and process data.
So basically the client requests and the server responds.
And all these requests of the client are independent of each other by design of HDP.
So when the Web browser makes the next request, this is completely unrelated to the previous one.
See, so that's why the server needs a mechanism to bind these requests if it does such tasks like adding
an item to a user's shopping cart or, well, doing anything that needs to be authenticated and stuff
like that.
So the most widely used technique to save the users state and exchange any metadata with a client is
through these cookies set by the server.
So servers can assign cookies in order to continue their interaction with a client.
So then after the initial request, the server issues a client, a cookie by setting the set cookie
field in the HDP response header.
And when a client receives this header, it will store the value of the cookie and then you see what
happens next.
It will automatically send this value with subsequent requests to the same server by just adding this
cookie header.
So by doing it this way, the server can treat their clients uniquely, as well as being able to follow
the user's behaviors.
So by assigning cookies, HTP Gaines's stateful position and makes every client or user unique.
Now the Web server or the owner of the Web application can assign many cookies to the client for any
purpose.
But the most important cookie is the one used for tracking the users, and that's called the session
ID in our terminology.
So as soon as user is authenticated with a valid username and password, a unique random session, ID
is assigned to that user.
And this session indeed should be included in each and every request that's made by the client.
So then the server would tie the request to the authenticated user of cookies, normally consist of
a name value pair where the value does not contain any space.
Also, the server can assign multiple cookies by adding multiple set cookie headers.
And multiple cookies sent back to the server and the same cookie had her separated by a semicolon.
And we're going to talk more about the security of cookies and their configurations in later sections.