Search code examples
djangodjango-sessions

Django session IDs for anonymous sessions


I see that a random (but not necessarily unique) session_key is generated for new sessions and this is stored in whichever session type you're using (cache, db, cookie).

The two queries I have are:

  1. Is a new session_key generated for all sessions, including anonymous ones
  2. Does the expiry of the anonymous sessions follow the same duration as a authenticated one - i.e. following SESSION_COOKIE_AGE or similar?

Solution

    1. Yes, even anonymous users get sessions.

    2. Yes. The documentation doesn't say much about the expiration of anonymous sessions but I am presuming it would follow the same rules.