See Coding with Node.js: Part 1; Getting started with Express. for the beginning of this tutorial series.
This is a supplemental post to the previous tutorial to add in session handling into Mongo. You may have noticed after the last tutorial that when running the code in production you are alerted that Connect does not recommend the use of in-memory session storage for productions systems.
Node is intended to be run as multiple processes on a larger production system and memory cannot be shared between these processes directly, so we will move the session storage to Mongo using session-mongoose.
To add in mongoose handling of your sessions you will need to install the session-mongoose package with npm (make sure to add to your package.json file) and specify the database to connect to. This is done as demonstrated below, at the same time I rearranged some of the code in the app.js file to be a little easier to follow:
You may want to play with the session timeouts to better fit your application.
All code created for this website is available on the github page and this tutorial specifically is available here: https://github.com/mikevalstar/mikevalstar_com/tree/Node_Tutorial_pt3.1