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。
( 用"connect-mongo": "~1.0.2",) store: new MongoStore({
}));(ps:不過還是有疑惑同樣的程式碼在coding的另一個帳號一直不對。)app.use(session({
secret: 'myblog',
key: db_config.module.database,/module.database,/module.database,/ /cookie name
cookie: {maxAge: 1000 60 60 24 30},//30 days
resave: false,
})