express4里要单独安装cookie-parser和express-session

express4里要单独安装cookie-parser和express-session:

1
2
npm install express-session --save
npm install cookie-parser --save

有关代码替换成

1
2
3
4
5
6
7
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

05-13 09:29