lzztt / koa-session-minimal

Minimal implementation of session middleware for Koa 2
MIT License
75 stars 13 forks source link

occur a waring #4

Closed yuu2lee4 closed 7 years ago

yuu2lee4 commented 7 years ago

i use it with koa-generic-session-mongo like this: app.use(session({ cookie: {maxAge: 1000 60 60 24 30},//30 days store: new MongoStore() }))

when i set: ctx.session.user = user , the shell tell me: (node:12780) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'maxAge' of undefined

node version: 7.2.0

lzztt commented 7 years ago

Hi yuu2lee4,

I think this may be caused by an obsolete set interface implemented by koa-generic-session-mongo.

The correct interface should be set(sid, sess, ttl): set session object for sid, with a ttl (in ms), for both koa-session-minimal and koa-generic-session.

It works for koa-generic-session because koa-generic-session stores a copy of cookie options in each session record in database, which is explicitly removed by koa-session-minimal, because we believe that cookie options are not session data.

I will create an Issue for koa-generic-session-mongo.

lzztt commented 7 years ago

There is already an Issue opened. I will update that one.

lzztt commented 7 years ago

set interface has been updated in koa-generic-session-mongo