koajs / generic-session

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

Session never destroyed #65

Closed jspdown closed 8 years ago

jspdown commented 8 years ago

Hi, I'm using generic-session with koa-redis on a side project and can't figure out how to destroy the session. I mean, I have a /logout route that is suppose to destroy the current session with the following code:

router.get('/logout', function *() {
  console.log('logout');
  this.session = null;
  this.status = 200;
});

As mentioned in the README.md, this.session = null should destroy the session but in fact nothing happened. I put some console.log in the destroy method of koa-redis and I noticed this function was never called.

FYI, modules versions are:

I try to make test in koa-redis and koa-generic-session and everything works as expected, 100% passed.

dead-horse commented 8 years ago

DEBUG= koa-redis node server to see the debug info? I test in a simple example, and works fine.

catamphetamine commented 8 years ago

Works for me too. You can add console.log()s inside your node_modules/koa-generic-session.

miserylee commented 8 years ago

when set rolling: true the bug happened. If another request come follow the 'logout' request, the request followed will resave the session in the store.

When I unset rolling , it works fine.

dead-horse commented 8 years ago

added some test cases for rolling session, anybody can reproduce the issue and create a test case?

https://github.com/koajs/generic-session/commit/0b1d52eb32aa0ace4c997277542decae4b07c2ec

tonystaark commented 4 years ago

The bug as raised by @miserylee is still there. How can we mitigate this issue if we need to use rolling:true for every request while making sure the session was destroyed if we call it to destroy?