Skip to content

Commit

Permalink
Ported old fix to avoid saving cookie if nothing changed
Browse files Browse the repository at this point in the history
  • Loading branch information
manuellazzari-cargoone committed Mar 15, 2024
1 parent 7a4a7e1 commit 4d2a627
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/flask_session/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ def save_session(self, app, session, response):
response.delete_cookie(
app.config["SESSION_COOKIE_NAME"], domain=domain, path=path
)
return
return None
elif not session.modified:
return None

# Get the new expiration time for the session
expiration_datetime = self.get_expiration_time(app, session)
Expand Down Expand Up @@ -315,7 +317,9 @@ def save_session(self, app, session, response):
response.delete_cookie(
app.config["SESSION_COOKIE_NAME"], domain=domain, path=path
)
return
return None
elif not session.modified:
return None

# Get the new expiration time for the session
expiration_datetime = self.get_expiration_time(app, session)
Expand Down Expand Up @@ -404,7 +408,9 @@ def save_session(self, app, session, response):
response.delete_cookie(
app.config["SESSION_COOKIE_NAME"], domain=domain, path=path
)
return
return None
elif not session.modified:
return None

# Get the new expiration time for the session
expiration_datetime = self.get_expiration_time(app, session)
Expand Down Expand Up @@ -522,7 +528,9 @@ def save_session(self, app, session, response):
response.delete_cookie(
app.config["SESSION_COOKIE_NAME"], domain=domain, path=path
)
return
return None
elif not session.modified:
return None

# Get the new expiration time for the session
expiration_datetime = self.get_expiration_time(app, session)
Expand Down Expand Up @@ -690,7 +698,9 @@ def save_session(self, app, session, response):
response.delete_cookie(
app.config["SESSION_COOKIE_NAME"], domain=domain, path=path
)
return
return None
elif not session.modified:
return None

# Serialize session data
serialized_session_data = self.serializer.dumps(dict(session))
Expand Down

0 comments on commit 4d2a627

Please sign in to comment.