Skip to content

Commit

Permalink
Fix expiry is None bug in SQLAlchemy
Browse files Browse the repository at this point in the history
Closes #203
Based on flask-session2 rather than other PRs as the expected behaviour would be to remove the session with no expiry
  • Loading branch information
Lxstr committed Dec 31, 2023
1 parent ef332d0 commit edd3a9c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/flask_session/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ def fetch_session_sid(self, sid):
store_id = self.key_prefix + sid
saved_session = self.sql_session_model.query.filter_by(
session_id=store_id).first()
if saved_session and saved_session.expiry <= datetime.utcnow():
if saved_session and (
not saved_session.expiry or saved_session.expiry <= datetime.utcnow()
):
# Delete expired session
self.db.session.delete(saved_session)
self.db.session.commit()
Expand Down

0 comments on commit edd3a9c

Please sign in to comment.