SESSION_COOKIE_AGE = 0, what will be the behavior of the session cookie in the browser?Setting SESSION_COOKIE_AGE = 0 makes the session cookie a browser-length cookie. This means it will expire when the user closes the browser, not immediately or never.
request.session.set_expiry(300) is called, what is the session expiry behavior?def my_view(request): request.session.set_expiry(300) return HttpResponse('Hello')
Calling set_expiry(300) sets the session to expire 300 seconds after the last request that modified the session.
Using set_expiry(None) sets the session to expire when the browser closes. Other values have different meanings or cause errors.
request.session.set_expiry(10) in a Django view, but the session never expires after 10 seconds. What is the most likely cause?If SESSION_SAVE_EVERY_REQUEST = True, the expiry time resets on every request, so the session never expires as long as the user keeps interacting.
request.session.set_expiry('invalid_string')?Django's set_expiry accepts only integers, None, or strings 'session' or 'never'. Any other string raises a ValueError.
