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

should_set_storage is duplicate of should_set_cookie #235

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 1 addition & 17 deletions src/flask_session/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,6 @@ def _sign(self, app, sid: str) -> str:
def _get_store_id(self, sid: str) -> str:
return self.key_prefix + sid

def should_set_storage(self, app: Flask, session: ServerSideSession) -> bool:
"""Used by session backends to determine if session in storage
should be set for this session cookie for this response. If the session
has been modified, the session is set to storage. If
the ``SESSION_REFRESH_EACH_REQUEST`` config is true, the session is
always set to storage. In the second case, this means refreshing the
storage expiry even if the session has not been modified.

.. versionadded:: 0.7.0
"""

return session.modified or app.config["SESSION_REFRESH_EACH_REQUEST"]

# CLEANUP METHODS FOR NON TTL DATABASES

def _register_cleanup_app_command(self):
Expand Down Expand Up @@ -298,15 +285,12 @@ def save_session(
response.vary.add("Cookie")
return

if not self.should_set_storage(app, session):
if not self.should_set_cookie(app, session):
return

# Update existing or create new session in the database
self._upsert_session(app.permanent_session_lifetime, session, store_id)

if not self.should_set_cookie(app, session):
return

# Get the additional required cookie settings
value = self._sign(app, session.sid) if self.use_signer else session.sid
expires = self.get_expiration_time(app, session)
Expand Down
Loading