0
0
Flaskframework~5 mins

Flask session object - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ASet
BList
CTuple
DDictionary
Which Flask setting is essential for session security?
Aapp.secret_key
Bapp.debug
Capp.static_folder
Dapp.config['SESSION_TYPE']
Where is Flask session data stored by default?
AIn a file on the server
BIn a server database
CIn a client-side cookie
DIn memory on the server
How do you remove a key from the Flask session?
ABoth A and B
Bdel session['key']
Csession.remove('key')
Dsession.pop('key')
What happens if a user tampers with the Flask session cookie?
AFlask ignores the tampered data
BFlask raises a security error
CFlask accepts the changes
DFlask resets the session silently
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.