Recall & Review
beginner
What is the purpose of Django's session framework?
Django's session framework stores and retrieves data on a per-site-visitor basis. It lets you keep information about users across requests without requiring them to log in.
Click to reveal answer
beginner
Where do you configure the session engine in a Django project?
You configure the session engine in the
settings.py file using the SESSION_ENGINE setting.Click to reveal answer
intermediate
Name two built-in session backends provided by Django.
Django provides several session backends, including:<br>-
django.contrib.sessions.backends.db (database-backed sessions)<br>- django.contrib.sessions.backends.cache (cache-backed sessions)Click to reveal answer
beginner
How does Django identify a user's session across requests?
Django uses a session ID stored in a cookie named
sessionid on the user's browser. This ID links the user to their session data on the server.Click to reveal answer
intermediate
What setting controls the duration a session lasts before expiring in Django?
The
SESSION_COOKIE_AGE setting controls how long a session cookie lasts in seconds. By default, it is set to 1209600 seconds (2 weeks).Click to reveal answer
Which setting in Django specifies the backend used to store session data?
✗ Incorrect
The correct setting is
SESSION_ENGINE. It defines which backend Django uses to save session data.By default, where does Django store session data?
✗ Incorrect
By default, Django stores session data in the database using the
django.contrib.sessions.backends.db backend.What cookie name does Django use to track sessions by default?
✗ Incorrect
Django uses the cookie named
sessionid to store the session ID.Which setting controls how long a session cookie lasts before expiring?
✗ Incorrect
The
SESSION_COOKIE_AGE setting defines the duration in seconds for session cookie expiration.If you want to store session data in cache instead of the database, which backend should you use?
✗ Incorrect
To store sessions in cache, use
django.contrib.sessions.backends.cache as the session engine.Explain how Django's session framework works to keep track of user data across requests.
Think about how the browser and server share information to remember a user.
You got /4 concepts.
Describe how to change the session storage backend in a Django project and why you might want to do that.
Consider different ways to store session data and their pros and cons.
You got /3 concepts.