var session = require("express-session");
const MongoStore = require("connect-mongo")(session);
app.use(session({
store: new MongoStore({
url:"mongodb://516fc3a8-ad11-4756-83e7-f87e5be83320:CC3sD-NW1y5tNy8fZFpHWA@192.168.3.8:27017/db22fba1-9f9f-415e-8f39-e1da8affca4c"
})
}));
-----------------------------------------------
if (process.env.VCAP_SERVICES) {
var mysql_config = JSON.parse(process.env.VCAP_SERVICES).mysql[0].credentials;
db_config.host = mysql_config.hostname;
db_config.port = mysql_config.port;
db_config.user = mysql_config.username;
db_config.password = mysql_config.password;
db_config.database = mysql_config.name;
}
var dbUrl = 'mongodb://' + db_config.use + ':' + db_config.password + '@' + db_config.host + ':' + db_config.port+'/'+db_config.database
mongoose.connect(dbUrl);
---------------------
我使用的
connect-mongo 1.0.2
express-session 1.13.0
大神们求解????试了很多网上的方法还是错误Error: Connection strategy not found。
迷茫2017-04-17 13:40:41
( 用"connect-mongo": "~1.0.2",)
app.use(session({
secret: 'myblog',
key: db_config.module.database,//cookie name
cookie: {maxAge: 1000 60 60 24 30},//30 days
resave: false,
saveUninitialized: true,
store: new MongoStore({
url: db_config.module.dbUrl //这里就是coding连接信息的uri
})
}));(ps:不过还是有疑惑同样的代码在coding的另一个帐号一直不对。)