Session at Node.JS

Asked

Viewed 1,093 times

1

I was reading that the middleware Express Session it is not ideal to work in production, because it archives the sessions in memory. I also read that storing session data in memory is not a good practice.

So my question is: how best to use Node.JS sessions?

  • Use express-session in conjunction with any of the various session storage modules... I recommend connect-mongo but, you can use mysql, Dynamo, couchbase, sqlite, redis, oracle, etc...

  • Storing session data in a database makes the request a little slower, doesn’t it? There is a way to store it on disk, as PHP does?

  • Yes, memory is faster. You can use a disk storage like session-file-store ... These "disk" storages are not recommended for large applications, as the system grows it must face competition problems in the read and write system. Databases are designed to work on this aspect allowing "parallelization" of competing calls, division of "pools", etc...

  • sessions, in general, are not the ideal currently pq makes your server does not comply with REST principles, specifically in not being stateless.

  • @guijob ? stateless is precisely the "lack of session", I believe that what this user seeks is "keep the state" and so search for a way to keep data in session!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.