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

KeyError: '_accessed_time' #180

Open
iinov opened this issue Sep 1, 2019 · 4 comments
Open

KeyError: '_accessed_time' #180

iinov opened this issue Sep 1, 2019 · 4 comments

Comments

@iinov
Copy link

iinov commented Sep 1, 2019

Hi,

I use Beaker as a session manager for a Pyramid project. With the 1.11.0 release, if I clear a session, I have the following error:

virtualenv/site-packages/beaker/session.py", line 465, in load
'_accessed_time' in session_data and
KeyError: '_accessed_time'

I suggest to fix it like this:

        if self.timeout is not None and \
           '_accessed_time' in session_data and \
           now - session_data['_accessed_time'] > self.timeout:
            timed_out = True
@amol-
Copy link
Collaborator

amol- commented Sep 1, 2019

Thanks for the report! Are you able to provide a simple test to reproduce the issue so that I can make it part of the test suite?

@iinov
Copy link
Author

iinov commented Sep 2, 2019 via email

@iinov
Copy link
Author

iinov commented Oct 6, 2019

Here is a simple test:

BeakerTest.tar.gz

I hope it will help you for the test suite.

kotofos added a commit to kotofos/beaker that referenced this issue Sep 24, 2020
Session.load does not properly handle state after .delete and .save was called.

This happens when user logs out, but saves session id, and then tries to use it again.
@kotofos
Copy link
Contributor

kotofos commented Sep 24, 2020

Have the same issue.
I see the next steps to reproduce in pyramid app:

  • Use persistent storage for sessions, set session.timeout
  • login
  • save received cookie
  • logout
  • send request with saved cookie value

Or in python:

from beaker.session import Session

COOKIE_REQUEST = {}
# login
session = Session(COOKIE_REQUEST, timeout=1)

saved_cookie = COOKIE_REQUEST['cookie_out']

# logout
session.delete()
session.save()


COOKIE_REQUEST['cookie'] = saved_cookie
Session(COOKIE_REQUEST, timeout=1)

amol- pushed a commit that referenced this issue Oct 8, 2020
Session.load does not properly handle state after .delete and .save was called.

This happens when user logs out, but saves session id, and then tries to use it again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants