Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Session.IsNew() always returns false if I use a db #1539

Closed
reedchan7 opened this issue Jun 17, 2020 · 1 comment
Closed

[BUG] Session.IsNew() always returns false if I use a db #1539

reedchan7 opened this issue Jun 17, 2020 · 1 comment

Comments

@reedchan7
Copy link

reedchan7 commented Jun 17, 2020

Describe the bug
Session.IsNew() always returns false if I use a db.

  • Iris version: v12.1.8

To Reproduce
A new HTTP request comes in with an empty cookie, the Start function is called by the middleware session.Handler(), then I found that s.provider.db.Len(sid) was 0 after a new sid was created, but after the line 87 invoked: sess := s.provider.Init(sid, s.config.Expires), s.provider.db.Len(sid) returns 1. so, session.IsNew() will always return false, even though it is a clean、new HTTP request.

Shall we swap the line 87 and 88 ?

Expected behavior
A new HTTP request comes in and session.IsNew() returns true correctly.

Screenshots
image

Desktop

  • OS: Ubuntu 18.04.4.LTS

Additional context
I use a redis to store my session info

@kataras
Copy link
Owner

kataras commented Jun 19, 2020

Hello @juan-chan, nice report. This is fixed with a commit to the master main branch.

This happened to redis and badger (boltdb is fine) because they fetching per prefix, which included the session id 'bucket/item' itself.

kataras added a commit that referenced this issue Jul 26, 2020
Former-commit-id: f2f277cd5cbe781ce596adc7840a1b1bc3b3bfc6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants