The last video we saw, what do we mean by cookies?
But in this video, we'll see what is a session for?
Session is a period of time when a browser interacts with a server.
So basically, when we log in to a web site, the session starts and a cookie gets created.
So whenever we need to use a page that requires authentication, they always check against that acto
cookie that is there on our browser session ends when we log or cookie that is related to the session
gets destroyed.
So basically when we open a website.
They're the browser.
Chicks caught up after cookie cutter active session.
So, for example, if you are logging into your Facebook or some other social networking app, you need
to log in using the password every time.
So once you log in, it will be remembered, you know, remember me for some time, I remember me for
a month, but they basically they're creating a session for that much amount of time.
So when they're following your browser finds the accusation, it will not ask for the password of genetically
logging.
Only when you click log out, then that cookie gets related to that session gets destroyed.
OK.
This is what happens.
So this is what session means.
It is basically a time in the browser in Bratislava.
And then based on this session, will create cookies that do cookies and destroy the cookies and everything.
So hullabaloo that OK be have understood the theory of setting up like, you know, creating cookies
and sessions and then destroying them and everything, but how to implement that in the code from then?
That is where the passport comes in.
We lose passports.
It is basically a simple and unobtrusive authentication for Node.js.
It up all sort of strategy supporting authentication like using username and password, using Google,
using Facebook, using Twitter and more for passport.
Jazz is something that everybody uses in its website.
And what are the documentation?
This is the website for it.
It will have many things it will have Google logged and everything.
So here, if you see it, it is a passport, Facebook passport, Twitter, Google or lot.
And then it will have many things like GitHub and it will get a passport so you can log in and do everything
the Google authentication part will see in the next related to final video.
So before that, there is one thing that you have to know how to install this passport, jazz and everything.
So for that, we'll see some quotes.
The first thing we have to require all the packages.
So what are all the packages that we have to request?
So there will be an Bayamon start.
It is the basic code and payment style for everything and what we have to construct.
We have to install a passport.
We have to install passport local.
We have to install.
Passport local.
Mongoose.
And then we have trained start express suspicion.
So.
Once we install them, you can require all the install packages if you've got to gorgeous.
You can request all of them like passport, local mungo's passport session and everything.
But one thing that is not required is passport local because it is one of the dependencies that will
be needed by the passport local most.
No need to record it explicitly.
So this passport, this is a soft model of that.
This is just a model of this passport local man was wanted to export, you know, required this separately
explicitly.
So after doing this, we have bought initialize the session.
So how to initialize the session?
This is also being of the session is I've got use session will send the secret resales false save and
save on initializes.
So this call we got from the documentation, you can check for the documentation here.
Everything will be in clear format, but we'll see the code that is required for our.
After doing this, this is basically initializing this app, not use passport, not initialize.
So if you see this?
Yeah, it is, I guess.
Yeah.
So if you see this court produce passport initialise, so I have initialized the passport and of initializing,
we have to use the session after this passport session and then at Passport Local Man List, what one
schema.
So we'll basically add this plugin passport local English to the user schema.
This is what we are going to use to hash in certain passwords and to save up use to database.
OK, schema should be a mongoose chemo.
So basically, if you are not using passport, even if you don't write, this one was keyboard, it
will work.
But since we are losing passport and then using passport plugins for that schema, here it should be
a mongoose schema.
So then using the passport local configuration, we can create strategies.
So this strategies that can be, you know, I'll show you.
Yeah, it can be.
Global strategy can be a Facebook strategy on all this kind of stuff.
So once we create the strategies, we'll see, it's creating strategies in the next Twitter that is
Google authentication.
Then serialize and DC delays are useful when we're creating sessions.
So what is serialize serialize means?
I will write it.
So what do you mean by we?
Legalized means.
Create a cookie.
And store information inside it.
And store.
Information inside it any more than we would be.
Serialize.
This basically.
Crumble the cookie and retrieve the information, crumble the cookie.
And retrieve the information.
This is what I mean by these intelligence serialize.
So if you've got any deprecation warnings, search them in Google to find the solutions.
OK.
So one thing we can do, right, but get pushed out score by checking the passport, local mungo's documentation
and BMJ is dot com.
OK.
So for registering, we can check the documentation of Passport Local Mongoose for logging and log what
you can check the documentation for passport just or documentation.
OK.
So one word of advice quickly gets deleted with no relation to seven.
So if you see this here, this is initializing everything, and then we are using the schema and then
we using created start again, then serialized user DC realizes he's a realizes it is a disease, as
you know, I want to give it to resources.
So here you can search for the log in and logout caught in this documentation and in that vein being
passport.
And that in the pocket baggage password passport, you can search for the register like you can see
serialized user serialized user.
And then logging strategies, and they will be done in this tool documentation, you can go to it.
But the basic idea is we have to understand what you are doing like what new passport means, what is
cookies, what is sessions and what do you mean by serialize?
And do you see that as an all those things?
So with this, we are completing the cookies and sessions now, the final part of our web pages, Google
authentication, how to use the Google servers to store the passports in their database and then access
give the user a choice of logging in with his Google or Facebook account.
It is basically all 2.0 will see that in the next.
That's it for this video.
Thank.