SESSION

//独立依赖的中间件cookie-session     npm install cookie-session
const express = require('express');
const cookieParser = require('cookie-parser');
const cookieSession = require("cookie-session");
var server = express();
server.use(cookieParser);
server.use(cookieSession(){keys:['ewfe','retqgteqrg']});//密钥建的越多越好
server.use('/',function(req,res){
  console.log(req.session);
  res.send('ok');
})
server.listen(8080);

你可能感兴趣的:(SESSION)