koajs / generic-session

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

bug of regenerateSession #110

Closed whosesmile closed 4 years ago

whosesmile commented 7 years ago

If I call regenerateSession, the old sessionId is destroyed, but when new session hash is equals to the originalHash, it wll not save new sessionId to sessionstore and cookie. (Old sessionHash equals new sessionHash is a common scene in my application, but maybe no for others.)

the source code: // rolling session will always reset cookie and session if (!options.rolling && newHash === originalHash) { return debug('session not modified'); }

maybe should add a condition like this: // rolling session will always reset cookie and session if (!options.rolling && newHash === originalHash && !isNew) { return debug('session not modified'); }

突然想起来貌似作者是国人,我可以写中文的...

fred1218 commented 7 years ago

@whosesmile 是的,作者好像是死马,他代码贡献最高,await co(ctx.regenerateSession()) 这样就可以解决,底层是yield实现的。不过node8都出了,async,await原生支持了,作者还不更新,估计他们都在玩egg哈哈。推荐: https://github.com/longztian/koa-session-minimal

whosesmile commented 7 years ago

@donggw2030521 thanks