save_session() — flask Function Reference
Architecture documentation for the save_session() function in sessions.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 58643c3f_4184_c18b_8361_a7d628d93359["save_session()"] 6e107b72_bfbc_d580_f6b3_676e4292673a["SecureCookieSessionInterface"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|defined in| 6e107b72_bfbc_d580_f6b3_676e4292673a 22e64eec_34fe_f9c3_c75a_bbd842b167e0["save_session()"] 22e64eec_34fe_f9c3_c75a_bbd842b167e0 -->|calls| 58643c3f_4184_c18b_8361_a7d628d93359 f653c3a8_c501_85ce_5865_f14ec4664394["process_response()"] f653c3a8_c501_85ce_5865_f14ec4664394 -->|calls| 58643c3f_4184_c18b_8361_a7d628d93359 6255d447_9270_b32e_3537_d10688208a06["get_cookie_name()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| 6255d447_9270_b32e_3537_d10688208a06 522c0d60_ef75_10cc_88d3_4d9ccebd6a54["get_cookie_domain()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| 522c0d60_ef75_10cc_88d3_4d9ccebd6a54 b6687bcd_1618_cb97_0b08_4df52250e96d["get_cookie_path()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| b6687bcd_1618_cb97_0b08_4df52250e96d def4e514_2812_db8f_9133_e44c29c504ff["get_cookie_secure()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| def4e514_2812_db8f_9133_e44c29c504ff 8664806b_8ac2_5d8d_7c97_c0f8d164f24e["get_cookie_partitioned()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| 8664806b_8ac2_5d8d_7c97_c0f8d164f24e f7e98be5_31d8_e5f5_ca82_ecbda038c0e5["get_cookie_samesite()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| f7e98be5_31d8_e5f5_ca82_ecbda038c0e5 e21674ac_874b_e0a2_10a3_9f42073cd29e["get_cookie_httponly()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| e21674ac_874b_e0a2_10a3_9f42073cd29e 2cf7467e_84a3_e5f7_ca7c_32bde50158e9["should_set_cookie()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| 2cf7467e_84a3_e5f7_ca7c_32bde50158e9 e9cd7e54_4bc9_3d51_b001_5bb10f298bfb["get_expiration_time()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| e9cd7e54_4bc9_3d51_b001_5bb10f298bfb e5e2a111_00ef_e01a_ff8b_016b8e6f11af["get_signing_serializer()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| e5e2a111_00ef_e01a_ff8b_016b8e6f11af 22e64eec_34fe_f9c3_c75a_bbd842b167e0["save_session()"] 58643c3f_4184_c18b_8361_a7d628d93359 -->|calls| 22e64eec_34fe_f9c3_c75a_bbd842b167e0 style 58643c3f_4184_c18b_8361_a7d628d93359 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/sessions.py lines 351–399
def save_session(
self, app: Flask, session: SessionMixin, response: Response
) -> None:
name = self.get_cookie_name(app)
domain = self.get_cookie_domain(app)
path = self.get_cookie_path(app)
secure = self.get_cookie_secure(app)
partitioned = self.get_cookie_partitioned(app)
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:
if session.modified:
response.delete_cookie(
name,
domain=domain,
path=path,
secure=secure,
partitioned=partitioned,
samesite=samesite,
httponly=httponly,
)
response.vary.add("Cookie")
return
if not self.should_set_cookie(app, session):
return
expires = self.get_expiration_time(app, session)
val = self.get_signing_serializer(app).dumps(dict(session)) # type: ignore[union-attr]
response.set_cookie(
name,
val,
expires=expires,
httponly=httponly,
domain=domain,
path=path,
secure=secure,
partitioned=partitioned,
samesite=samesite,
)
response.vary.add("Cookie")
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does save_session() do?
save_session() is a function in the flask codebase, defined in src/flask/sessions.py.
Where is save_session() defined?
save_session() is defined in src/flask/sessions.py at line 351.
What does save_session() call?
save_session() calls 11 function(s): get_cookie_domain, get_cookie_httponly, get_cookie_name, get_cookie_partitioned, get_cookie_path, get_cookie_samesite, get_cookie_secure, get_expiration_time, and 3 more.
What calls save_session()?
save_session() is called by 2 function(s): process_response, save_session.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free