Skip to content

Commit

Permalink
Fix empty session being set
Browse files Browse the repository at this point in the history
save_session method relies on checking if a session is empty to return early. This fixes the boolean evaluation of a permanent but empty session evaluating as True.

Closes #193
  • Loading branch information
Lxstr committed Jan 5, 2024
1 parent edd3a9c commit 20f834a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/flask_session/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def total_seconds(td):

class ServerSideSession(CallbackDict, SessionMixin):
"""Baseclass for server-side based sessions."""

def __bool__(self) -> bool:
return bool(dict(self)) and self.keys() != {"_permanent"}

def __init__(self, initial=None, sid=None, permanent=None):
def on_update(self):
Expand Down

0 comments on commit 20f834a

Please sign in to comment.