koajs / generic-session

koa session store with memory, redis or others.
MIT License
414 stars 65 forks source link

ctx.session this.session ? #121

Closed maxushuang closed 7 years ago

maxushuang commented 7 years ago

in my routers.

const router = require('koa-router')();
router.get('/', async (ctx, next) => {
this.session.user={}  // types error ,this.session is undefined,
ctx.session.user= {} // it's success, 
})

in my entry's

const Koa = require('koa');         //koa versersion 2.2
const session = require('koa-generic-session');
const app = new Koa();
app.keys=['secret'];
app.use(session());

I cannot use this.session, there is something wrong with my use? Can you help me with it? Thank you. 求解答