Recall & Review
beginner
What is a cookie-based session in Django?
A cookie-based session stores all session data directly inside the user's browser cookie. Django signs the cookie to prevent tampering but does not store session data on the server.
Click to reveal answer
beginner
How does a database session work in Django?
A database session stores session data on the server in the database. The user's browser only keeps a session ID cookie that references the stored data.
Click to reveal answer
intermediate
Name one advantage of cookie-based sessions.
They reduce server load because session data is stored on the client side, so the server does not need to read or write session data for each request.
Click to reveal answer
intermediate
What is a key security concern with cookie-based sessions?
Since session data is stored on the client, it can be exposed if not properly secured. Although signed, sensitive data should not be stored in cookies to avoid leaks.
Click to reveal answer
intermediate
Why might you choose database sessions over cookie-based sessions?
Database sessions allow storing larger and more complex data securely on the server, and they avoid exposing session data to the client.
Click to reveal answer
In Django, where is session data stored when using cookie-based sessions?
✗ Incorrect
Cookie-based sessions store all session data inside the user's browser cookie.
What does Django store in the user's cookie when using database sessions?
✗ Incorrect
Django stores only a session ID in the cookie, which references the session data stored in the database.
Which session type reduces server storage needs?
✗ Incorrect
Cookie-based sessions store data on the client side, reducing server storage needs.
What is a risk of storing sensitive data in cookie-based sessions?
✗ Incorrect
Sensitive data in cookies can be exposed or tampered with despite signing, so it is risky to store it there.
Which session type is better for storing large amounts of data securely?
✗ Incorrect
Database sessions store data securely on the server and can handle larger data sizes.
Explain the main differences between cookie-based sessions and database sessions in Django.
Think about client vs server storage and what each session type keeps in the cookie.
You got /4 concepts.
When would you choose to use cookie-based sessions over database sessions in a Django project?
Consider performance and data sensitivity.
You got /3 concepts.