0
0
Djangoframework~20 mins

Cookie-based sessions vs database sessions in Django - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Session Mastery in Django
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference in data storage location
Where is session data stored when using cookie-based sessions compared to database sessions in Django?
ACookie-based sessions store all session data on the client inside cookies; database sessions store session data on the server in the database.
BCookie-based sessions store session data in the database; database sessions store data inside cookies on the client.
CBoth cookie-based and database sessions store session data only in server memory.
DCookie-based sessions store session data in temporary files; database sessions store data in browser local storage.
Attempts:
2 left
💡 Hint
Think about where the session data physically lives in each method.
component_behavior
intermediate
2:00remaining
Session size limits impact
What happens if you try to store a large amount of data in a cookie-based session in Django?
AThe data will automatically be split across multiple cookies without issues.
BThe session data will be truncated or cause errors because cookies have size limits.
CThe session data size is unlimited in cookie-based sessions.
DDjango will store the extra data in the database automatically.
Attempts:
2 left
💡 Hint
Consider browser cookie size limits.
🔧 Debug
advanced
3:00remaining
Session data loss troubleshooting
A Django app using cookie-based sessions loses session data unexpectedly after a user logs in. Which of the following is the most likely cause?
AThe session cookie is not marked as secure and is blocked by the browser.
BThe database storing sessions is down.
CThe session data exceeds the cookie size limit and is truncated.
DThe server's cache is full.
Attempts:
2 left
💡 Hint
Think about cookie size limits and how that affects cookie-based sessions.
📝 Syntax
advanced
2:00remaining
Configuring database sessions in Django
Which setting correctly configures Django to use database-backed sessions?
ASESSION_ENGINE = 'django.contrib.sessions.backends.db'
BSESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
CSESSION_ENGINE = 'django.contrib.sessions.backends.cache'
DSESSION_ENGINE = 'django.contrib.sessions.backends.file'
Attempts:
2 left
💡 Hint
Database sessions use the 'db' backend.
state_output
expert
3:00remaining
Session data persistence after server restart
In a Django app using database sessions, what happens to session data after the web server restarts?
ASession data persists only if the server cache is warmed up.
BSession data is lost because it is stored only in server memory.
CSession data is lost because cookies are cleared on server restart.
DSession data persists because it is stored in the database.
Attempts:
2 left
💡 Hint
Think about where the session data lives and what survives a server restart.