express4里要单独安装cookie-parser和express-session
express4里要单独安装cookie-parser和express-session:
npm install express-session --save npm install cookie-parser --save
有关代码替换成
var cookieParser = require('cookie-parser') var session = require('express-session') app.use(cookieParser()) app.use(session({ secret: 'imooc' }))
参考地址:
https://github.com/expressjs/cookie-parser
https://github.com/expressjs/cookie-session