标签:登陆 str use key let -- dev Koa 配置
//--------------koa2设置---------------------------
1.安装:
npm install koa-generic-session --save-dev
2.修改app.js
var session = require(‘koa-generic-session‘);
app.keys = [‘my secret key‘];
app.use(session());
3.代码
let user = {};
user.id=1;
user.nicheng = ‘张三‘;
ctx.session.user = user;
console.log(ctx.session.user);
console.log(ctx.session);
console.log(ctx.session.user);
-------------------设置session.loginbean代替传入的数据user-----------
ctx.session.loginbean = user;
ctx.body=‘登陆成功‘
标签:登陆 str use key let -- dev Koa 配置
原文地址:https://www.cnblogs.com/xintao/p/9990174.html