为了账号安全,请及时绑定邮箱和手机立即绑定

express-session和cookie-session的区别

express-session和cookie-session的区别

夜千寻 2017-08-09 14:06:02
var express = require('express')  , cookieParser = require('cookie-parser')  , session = require('cookie-session')  , express_sess = require('express-session')  , app = express();//====================================================app.use(cookieParser())// app.use(session({ keys: ['abc'], name: 'user' }));// {}// { 'connect.sid': 's:cpI6_ewOlAoRIl0kGkwRVOOZAQnA0n_t.9Q1cv7SP1ADoHArxmqtqQEEXyQE// fRjaWxsXnQTY4bLI' }//====================================================app.use(express_sess({ secret: 'abc', key: 'user'}));// req.session: { cookie: { //      path: '/',//      _expires: null,//      originalMaxAge: null,//      httpOnly: true //    } // }// req.cookie: {user: 's:aJ97vKA5CCwxqdTj0AV1siRQ.fWusS5+qfCKICtwkfrzcZ/Gq8P0Qdx/kx8mTBhoOhGU'}app.get('/', function (req, res, next) {    res.end(JSON.stringify(req.cookies));    console.log(req.session)    console.log(req.cookies)});app.listen(3000);cookie-sessio 和express-session 的区别,和适用场合?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1607 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信