Recall & Review
beginner
What is the Flask
session object used for?The Flask
session object stores data specific to a user across requests. It keeps information like login status or preferences while the user browses the site.Click to reveal answer
intermediate
How does Flask keep session data secure?
Flask signs the session data with a secret key to prevent tampering. This means users cannot change the session data without the server noticing.
Click to reveal answer
beginner
How do you store a value in the Flask session?
You assign a value like a dictionary: <br>
session['key'] = 'value'. This saves the value under 'key' for the current user session.Click to reveal answer
beginner
What must you set in your Flask app to use sessions?
You must set
app.secret_key to a secret string. This key signs the session cookies to keep them secure.Click to reveal answer
intermediate
What happens if you don’t set a secret key in Flask but try to use sessions?
Flask will raise an error because it cannot securely sign the session cookie. The secret key is required to protect session data.
Click to reveal answer
What type of data structure is the Flask
session object similar to?✗ Incorrect
The Flask session object behaves like a dictionary where you store key-value pairs.
Which Flask setting is essential for session security?
✗ Incorrect
The secret_key is used to sign session cookies and keep them secure.
Where is Flask session data stored by default?
✗ Incorrect
By default, Flask stores session data in a signed cookie on the client side.
How do you remove a key from the Flask session?
✗ Incorrect
You can remove a key using either session.pop('key') or del session['key'].
What happens if a user tampers with the Flask session cookie?
✗ Incorrect
Flask detects tampering because the cookie signature won't match and raises an error.
Explain how Flask sessions help keep user data across multiple page visits.
Think about how websites remember you when you move between pages.
You got /4 concepts.
Describe the steps to securely use the Flask session object in an app.
Consider what you need to do before and after using session data.
You got /4 concepts.