A very simple and lightweight session manager
Configuration options:
Session.sessionLifeTime Number, default is 60000 * 30, which is 60 min
Session.maxSize Number, Max size of all data stored per session in bytes, default is 262144 bytes
Session.sessionName String, Name of the session cookie, default is 'nodesess';
usage:
var Session = require('../index').Session; var http = require('http');
var srv = http.createServer(function (req, res) { // initialize a session object on each request, pass the request and // response objects to it it will discover if session is alread set, and // create one if it isn't var session = new Session(req, res);
// set foo session property value to bar
session.setData('foo', 'bar');
// get foo session property value and print it to console
console.log(session.getData('foo'));
// delete foo session property value to bar
session.delData('foo');
// print 'foo' session property to console, it must return undefined
console.log(session.getData('foo'));
....
}); srv.listen(1111, '127.0.0.1');