Cookies¶
The one place the session cookies are set, cleared and read - with the same flags every time.
Read from the code itself, so it never falls behind it. The descriptions are the code's own, in English.
set_session_cookies
¶
set_session_cookies(response: ResponseT, *, access: str, refresh: str, lifetime: timedelta | None = None) -> ResponseT
Put a signed-in session on response: both tokens, in their cookies.
Both cookies last as long as the refresh token - lifetime, or
simplejwt's REFRESH_TOKEN_LIFETIME. The access cookie deliberately
outlives the access token inside it: if it expired with the token, the
browser would delete it the moment the token ran out, and there would be
nothing left to renew - the person would be signed out with a refresh
token that had weeks left on it.
set_access_cookie
¶
set_access_cookie(response: ResponseT, access: str, *, lifetime: timedelta | None = None) -> ResponseT
Replace only the access cookie - what a silent renewal does.
clear_session_cookies
¶
Remove both cookies, with the flags they were set with.
A browser does not delete a cookie when the path, the domain or SameSite differ: it keeps the first and writes a second, empty one - a session that cannot be ended.
read_access_token
¶
The access token the browser sent, or ''.
read_refresh_token
¶
The refresh token the browser sent, or ''.