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

Dont expire sessions using TTL based on time passed since creation #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion flask_kvsession/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ class KVSessionInterface(SessionInterface):
serialization_method = pickle
session_class = KVSession

def _session_has_expired(self, sid, app):
if getattr(app.kvsession_store, 'ttl_support', False):
return False
return sid.has_expired(app.config['PERMANENT_SESSION_LIFETIME'])

def open_session(self, app, request):
key = app.secret_key

Expand All @@ -145,7 +150,7 @@ def open_session(self, app, request):
session_cookie).decode('ascii')
sid = SessionID.unserialize(sid_s)

if sid.has_expired(app.permanent_session_lifetime):
if self._session_has_expired(sid, app):
# we reach this point if a "non-permanent" session has
# expired, but is made permanent. silently ignore the
# error with a new session
Expand Down