0
0
Djangoframework~5 mins

Session framework configuration in Django - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ASESSION_ENGINE
BSESSION_BACKEND
CSESSION_STORE
DSESSION_HANDLER
By default, where does Django store session data?
AIn browser local storage
BIn the database
CIn a file on the server
DIn the cache only
What cookie name does Django use to track sessions by default?
Adjango_session
Buser_session
Csessid
Dsessionid
Which setting controls how long a session cookie lasts before expiring?
ASESSION_COOKIE_AGE
BSESSION_TIMEOUT
CSESSION_EXPIRY
DSESSION_LIFETIME
If you want to store session data in cache instead of the database, which backend should you use?
Adjango.contrib.sessions.backends.file
Bdjango.contrib.sessions.backends.db
Cdjango.contrib.sessions.backends.cache
Ddjango.contrib.sessions.backends.signed_cookies
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.