Onyx
Onyx

Reputation: 5782

Equivalent of session_start() and $_SESSION in Node.js/Express

I am trying to find the equivalent of session_start() and $_SESSION in Node.js/Express in order to put the id of the current user in the session. Almost every video/tutorial uses express-session but I read that :

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.

Do I need a certain module to achieve that?

Upvotes: 5

Views: 1334

Answers (1)

tfogo
tfogo

Reputation: 1436

You should connect express-session to a database in which it can store sessions. There's a list of compatible session stores in the documentation: https://github.com/expressjs/session#compatible-session-stores

Using MongoDB is a popular choice (https://github.com/jdesboeufs/connect-mongo) but you could use any modules in the list above.

Upvotes: 2

Related Questions