What is the best way to manage session variables in Node.js? Is there any library?
What is the best way to manage session variables in Node.js? Is there any library?
Donald's answer is good - once you get into the onion pattern of connect middleware you have to make a decision on what type of session store to use. The default one in express is a MemoryStore, and is not intended for production use. Here are some of your choices:
Mongo https://github.com/mikkel/express-session-mongo - Be sure to use the option 'native_parser:false'
Redis https://github.com/visionmedia/connect-redis - Very good, but if you aren't already using redis for pub/sub or storage it might not be ideal.
Note, there are other choices - it depends on your project. Look for something you can introduce leveraging your existing technology stack.