npm install mongosessionstore github: https://github.com/lodengo/MongoSessionStore.git store session in mongodb for express 参考: https://github.com/kcbanner/connect-mongo
usage:
//session store: app.use(express.session({ cookie: { maxAge: 2 * 60 * 1000 } ,secret: “session secret” ,store: new MongoSessionStore({mongodb_connection_url:"mongodb://127.0.0.1:27017/test", mongoclient_connect_options:{}}) }));
//session set: req.session.name = 'MongoSessionStore’;
//session get: var name = req.session.name;
//session destory req.session.destroy();
mongodb_connection_url, see: http://mongodb.github.com/node-mongodb-native/driver-articles/mongoclient.html http://docs.mongodb.org/manual/reference/connection-string/
session expire see: http://docs.mongodb.org/manual/tutorial/expire-data/
dependencies: "mongodb":"1.2.8", "express": “3.0.3”