پرش به محتویات

کوکی‌ها

تنها جایی که کوکی‌های نشست گذاشته، پاک و خوانده می‌شوند - هر بار با همان پرچم‌ها.

از خود کد خوانده می‌شود، پس هیچ‌وقت از آن عقب نمی‌ماند. توضیح‌ها مال خود کد هستند، به انگلیسی.

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(response: ResponseT, access: str, *, lifetime: timedelta | None = None) -> ResponseT

Replace only the access cookie - what a silent renewal does.

clear_session_cookies

clear_session_cookies(response: ResponseT) -> ResponseT

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

read_access_token(request: HttpRequest) -> str

The access token the browser sent, or ''.

read_refresh_token

read_refresh_token(request: HttpRequest) -> str

The refresh token the browser sent, or ''.