1. 程式人生 > >nodejs-5.7 express-session

nodejs-5.7 express-session

str tex you bsp all expressjs sof .com size

express-session
官網: https://github.com/expressjs/session


1. 安裝 cnpm install express-session --save
2. 引入並設置
  var session = require(‘express-session‘);

  app.use(session({
    secret: ‘iloveyou‘,
    resave: false,
    saveUninitialized: false
  }));

3. 設置session: req.session.username = ‘lisi‘;

 獲取session: req.session.username

nodejs-5.7 express-session