express-mongoose模块存储session
发布于 2 个月前 作者 0xReturn 311 次浏览 来自 问答

刚入门node.js,在研究将session存入mongodb,总是报错,核心代码如下: ####我的环境:

  • Express4.13
  • MongoDB2.6.2
var express       = require('express')
var session       = require('express-session')
var connect       = require('connect')
var SessionStore  = require("session-mongoose")(connect)
var SESSION_URL   = 'mongodb://localhost/session'

var store = new SessionStore({
	url:SESSION_URL,
	interval: 120000
});
app.use(session({
	secret : '123456',
	store  : store,
	cookie : {maxAge:10000}
}))

报错如下: …/node_modules/session-mongoose/index.js:266 })(connect.session.Store); TypeError: Cannot read property ‘Store’ of undefined at module.exports (/home/proj/node/movie/node_modules/session-mongoose/index.js:266:23)

1 回复

我记得用https://github.com/jdesboeufs/connect-mongo存session比较多

回到顶部