forked from orbit-oss/flask
set Vary: Cookie header consistently for session
This commit is contained in:
parent
a6367dac74
commit
8646edca6f
3 changed files with 30 additions and 4 deletions
|
|
@ -383,6 +383,10 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
samesite = self.get_cookie_samesite(app)
|
||||
httponly = self.get_cookie_httponly(app)
|
||||
|
||||
# Add a "Vary: Cookie" header if the session was accessed at all.
|
||||
if session.accessed:
|
||||
response.vary.add("Cookie")
|
||||
|
||||
# If the session is modified to be empty, remove the cookie.
|
||||
# If the session is empty, return without setting the cookie.
|
||||
if not session:
|
||||
|
|
@ -395,13 +399,10 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
samesite=samesite,
|
||||
httponly=httponly,
|
||||
)
|
||||
response.vary.add("Cookie")
|
||||
|
||||
return
|
||||
|
||||
# Add a "Vary: Cookie" header if the session was accessed at all.
|
||||
if session.accessed:
|
||||
response.vary.add("Cookie")
|
||||
|
||||
if not self.should_set_cookie(app, session):
|
||||
return
|
||||
|
||||
|
|
@ -417,3 +418,4 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
secure=secure,
|
||||
samesite=samesite,
|
||||
)
|
||||
response.vary.add("Cookie")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue