YouSub
Untitled

en English

Untitled English subtitles

0 downloads · 86 lines · added Nov 21, 2015

Report a problem
What's wrong?
Advertisement

English transcript

Let's talk about the session management and how the user
interface works inside the blog.
You don't actually need to completely understand this to
do the problem this week, but it's good to have a basic
understanding of it.
So they have MongoDB, and--
here I'll show it as this, running as a mongod process.
And you have your application.
And your application is written in Java.
And inside it, it's got FreeMarker, which is a
templating engine for the views, which I'll show you,
and then Spark Application Server.
So initially you're going to sign up.
And so you're going to do a GET request, right here, that
is going to result in the page coming back to you, the
sign-up page, with a bunch of fields, four fields.
This is the reply from the GET.
And then you're going to submit that with a bunch of
information with a post.
And at this point, what's going to happen is the
application, if it's a valid sign up, is going to respond
with a redirect to the welcome page.
Now they'll also be a cookie set.
And this is an important part of the process, because the
application server before it does this redirect and after
it crosses your post of your sign-up information-- this is
the sign up form.
So when it processes this post, it's going to write the
users table.
So it's going to write the users table.
It's also going to write the sessions table
and start a new session.
And it's going to take a piece of information from the
sessions collection.
I should really call it a collection not a table, it
would be more accurate.
And it's going to set that the cooking in the redirect.
So when your browser does a GET of the welcome page--
here's the welcome page--
it's going to present that cookie.
So the redirect generates a GET, which generates a reply
on this page that's going to welcome you, individually.
Welcome Andrew.
So how does that work?
Well on that redirect, the cookie is set, and now your
browser is going to present that cookie.
And that cookie is going to be checked.
When the welcome page gets processed, the database-- the
application, rather, is going to do a read query to Mongo,
and say oh, do I recognize that session cookie.
And if I do, who's the user?
And then, show me the right information.
So all the session management happens via this cookie, which
rendezvous the information from request to request with
the user information.
So let me show you specifically what I mean.
So here's the blog itself.
And you can see it's welcomed me right now.
And I'm on the welcome page.
This is after I signed up.
I've downloaded a cookie utility, which you can
download as well, if you want.
And this cookie utility will show me the cookies the
browser's going to present to the website.
In this case, you can see that it's presenting this long
random string starting with VBL.
And if you look here, in MongoDB, you can see when we
looked at the sessions table, here was that same cookie,
right here.
The same piece of information.
So when the web browser requested the welcome page
with the cookie, then the application looked up and said
oh, it must be this user, erlichson, and then it
presented my information.
And it customized the page accordingly, right here.
So just again, if you go to the login page, right, what's
going to happen is when I type in one username and password
here, like erlichson, and if I type the right one, then there
was just a round trip, where in response to the post, the
application responded with a redirect to the welcome page
along with the cookie that is set properly,
associated with my user.
All right, so now that we understand the way the session
management works, then I'm going to go through some of
the way the code is structured, so you understand
the way it all fits together.

Need subtitles from another video?