Session Handling for NodeJS' HTTP Server
session-manager provides a session management layer around node's built in http server using cookies.
Usage example
This example builds on Node's example web server, and responds with an incrementing count, per user.
var http = ;var sessionManager = ; // Best to use one shared session manager across requestsvar sessionManager = sessionManager; // Usage with Node's HTTP Serverhttp;console;
Storage engines.
It supports various (and extensible) data storage engines. Currently included ones are:
- file (stores data on disk)
- memory (keeps data in array, useful for development, as restarting node will reset values)
Storing session data another way (creating new storage engine)
It is simple to create a new storage engine, e.g. redis by creating an object with two function keys, set(session_id, key, val)
and get(session_id, key)
.
The simplest example to base this on is the memory engine (./engines/memory.js).