koajs / generic-session

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

regenerateSession是不是有问题 #109

Closed fred1218 closed 4 years ago

fred1218 commented 7 years ago

this.regenerateSession,你文档中说

Calling this.regenerateSession will destroy any existing session and generate a new, empty one in its place. The new session will have a different ID.

但是,我在保存session时,调用这个方法,为什么sessionid还是同一个,你源码里加那个判断干嘛,,,我需要sessionId不同,以配合安全测试

fred1218 commented 7 years ago

image

fred1218 commented 7 years ago

打开登录页时: image

fred1218 commented 7 years ago

do login: image 输出见第一张图,为嘛sessionId没变化。。

fred1218 commented 7 years ago

。。我的错,,yield

fred1218 commented 7 years ago

await co(ctx.regenerateSession()) 这样就Ok了,。。不过大神干嘛不重构下代码完美支持KOA2,感觉在koa2中这样用不伦不类啊。。。。

kingjerod commented 7 years ago

I am seeing this problem too. Calls to await ctx.regenerateSession() seem to do nothing. Turning on debug, I never see the debug('regenerating session'); message. It's possible this does not work with Koa v2. I'm using the conversion posted here: https://github.com/koajs/generic-session/issues/59

kingjerod commented 7 years ago

@donggw2030521 I switched over to using https://github.com/longztian/koa-session-minimal

It's a drop in replacement for this library and supports Koa v2 async/await. The only difference I've found is you call await ctx.sessionHandler.regenerateId(); to get a new session id.