N
N
Nwton2016-06-11 18:41:11
Node.js
Nwton, 2016-06-11 18:41:11

How do sessions work?

1) Let's say the user entered the login and password, sent it to the server, the server checked for the presence of the user and the match login: pass.
2) If everything is OK, then we generate a random string and write it to cookies. We save the same string to the database, to table X of the form login + string.
3) When updating a page / switching to others, we send cookies with a string to the server and look for a string in table X. If there is such a string, then we identify the user by sending a login corresponding to the string in response.
Does the session system work like this and is such an implementation sufficient or have I missed something?
And if everything is so simple, then why use third-party modules to implement sessions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2016-06-11
@Nwton

There are a lot of releases, your version will work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question