E
E
evg_962017-09-25 20:23:47
JavaScript
evg_96, 2017-09-25 20:23:47

Where can I read about sessions and working with them in node.js?

Actually the question is in the title. Preferably in Russian and preferably without using any framework. In general, to understand what, how and why.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RidgeA, 2017-09-25
@RidgeA

A session is just a store of data that is available for different requests. They are usually made available by some sort of user ID.
There is no built-in session mechanism in NodeJs. Usually, middleware is used for this, which clings to request handlers and gets the user ID from cookies and gets the necessary data in some storage. Anything can act as a storage - a variable in RAM, files on disk, a database, a remote service. It is convenient to use memcached/Redis. This mechanism is usually implemented by a framework or an already existing middleware package for working with sessions.

A
Abcdefgk, 2017-09-25
@Abcdefgk

The HTTP protocol is a "stateless protocol". A "session" ("session") is when a user logs in to the site, walks through its different pages - and the server recognizes it everywhere, on all pages: Oh! it's the same user! In accordance with the internal structure of the protocol - should not recognize (each new page - a new state), - but recognizes the dog.
That's the whole theory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question