Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

node7,koa2,koa-session2写cookie失败,操作cookie需要用哪个中间件吗,客户端angular2

$
0
0
const Koa = require('koa');
const session = require("koa-session2");
const Store = require("./Store.js");
const app = new Koa();
app.use(session({
    key: "SESSIONID",   //default "koa:sess"
    //store: new Store()
}));
app.use(async (ctx, next) => {
  ctx.session.user = 'aaa';
  ctx.cookies.set("SESSIONID", 'sdfwfswed', {key: "SESSIONID"});
  ctx.cookies.get("SESSIONID", {key: "SESSIONID"});//undefined
});

无论是设置session键值还是手工设置cookie,都失败,客户端下次请求cookie一直为空 DX帮忙看看,谢谢


Viewing all articles
Browse latest Browse all 14821

Trending Articles