I'm learning ExpressJS, and I want to make a Register-Login system.
I'm reading about express-session
and it seems kind of easy to use but I wonder,
Can U guys give me some blog post about this ? Thank U
Where is the session data stored? It depends on how you set up the express-session module. All solutions store the session id in a cookie, and keep the data server-side. The client will receive the session id in a cookie, and will send it along with every HTTP request.
On the other hand, the session data is stored on the server-side, i.e., a database or a session store. Hence, it can accommodate larger amounts of data. To access data from the server-side, a session is authenticated with a secret key or a session id that we get from the cookie on every request.
The session store instance, defaults to a new MemoryStore instance.
We can use the express-session package to keep session cookie data on the server-side. There're many options like the content of various cookie attributes and the time to expiry. Other settings like the ID, whether to save cookie only in HTTPS and so on can be set. The cookies will be stored in a session store.
If you don't supply express-session with a storage mechanism, then it just uses a lightweight memory store. Thus, it is not persisted across server restarts.
From the doc:
store
The session store instance, defaults to a new MemoryStore instance.
The MemoryStore
comes with these warnings:
Warning The default server-side session storage, MemoryStore, is purposely not designed for a production environment. It will leak memory under most conditions, does not scale past a single process, and is meant for debugging and developing.
For a list of stores, see compatible session stores.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With