Welcome back.
In this video, let's get started with cookie based authentication, where we are going to improve the
previous concept by adding what is called cookie based authentication to it.
All right.
So let's see, what is cookie or what are cookies?
Well, here we go.
Cookies in programming is not real cookies, as you see in reality, but instead it is a string of characters.
But let's see in details.
So cookies are a small text file that is stored on your browser, which contains data from the websites
that you visit.
So a cookie is a kind of ways of storing data, and we can use cookies to implement what is called authentication.
If cookies are a file that stores data.
It means that we can store the user login details onto the file and upon every request we are going
to check if there is user inside the cookies and that is it.
So let's look at some facts about cookies.
That is some properties and why do we need cookies?
The first point is that it is used in session management.
Like I would say that servers are stateless, but if we are able to implement session, it means that
our server will be able to remember the log in user.
So upon every request our server is going to check the session if there is a user and I'll show it to
you with code, let's continue on.
The next point is that cookies are stored with key value per and with some optional attributes, meaning
that we can save the user name with a value and a password with a value also inside our browsers.
The next point is that we don't need to install any package before we can use cookies by default.
Express has this one for us, so to use cookies, you don't need to install any package from NPM or
from the core modules, but instead express get us covered.
The next point is that but we need a package to send back the cookie back to the server upon each request
so our server can generate a cookie by default.
But if you want to get a cookie from the browser into our server to check if a user has been logged
in, we need a third party package called Cookie Parcel, meaning we are going to pass the cookie in
the browser and then use inside our route to check the user upon each request.
And I'll show you this one also.
The next point is that cookies can be used to keep track user activity on the side.
So in this case, the application can provide a personalized experience for the user, such as remembering
the user name or any other preferences.
And I believe you see some of these features in most applications.
The next point is that we use cookies to store data about the current user, and this is what we call
the use insertion management.
So this information can be used to analyze website usage and improve the user experience.
So additionally, cookies can be used to serve target advertising to users.
So most advertising companies like YouTube and Facebook, they use cookies.
In that way they can display a specific advert based on the need or your location.
So with this one being said, the next video, let's see how we can get started with cookie based authentication.