我将connect-mongo模块用于 mongo 会话存储
var express = require('express');
var http = require('http');
var mongoose = require('mongoose');
var db = 'mongodb://localhost:27017/test';
mongoose.connect(db);
mongoose.connection.on('open',function(db){
console.log('connected ??')
})
var MongoStore = require('connect-mongo')(express);
……
app.use(express.cookieSession({
secret : 's3cr3t',
store : new MongoStore({
mongoose_connection : mongoose.connection
}),
cookie : {
maxAge : 60000 // 60k msconds
}
})
我可以看到已connected?
登录的 . 但是当我打开 mongo 尝试 db.sesssions.find() 时,它什么也没有。我给了隐身请求,即清除了cookie,但数据库只是空的,但创建了测试数据库和会话集合