0
0
Flaskframework~5 mins

Session data storage in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is session data storage in Flask?
Session data storage in Flask is a way to keep user-specific information across multiple requests. It stores data on the server or client to remember user actions or preferences during their visit.
Click to reveal answer
beginner
How does Flask store session data by default?
By default, Flask stores session data on the client side inside a secure cookie. This cookie is signed to prevent tampering but can only hold small amounts of data.
Click to reveal answer
beginner
What is the purpose of the secret key in Flask sessions?
The secret key is used to sign the session cookie. It ensures that the data stored in the cookie has not been changed by the user, keeping session data secure.
Click to reveal answer
beginner
How do you set a value in the Flask session?
You set a value in the Flask session like a dictionary: <br>session['key'] = 'value'. This saves the data for the current user across requests.
Click to reveal answer
intermediate
Why might you use server-side session storage instead of Flask's default?
Server-side session storage is used when you need to store more data or keep data private from the client. It stores session data on the server, improving security and capacity.
Click to reveal answer
Where does Flask store session data by default?
AIn a signed cookie on the client
BIn a database on the server
CIn a file on the server
DIn local storage of the browser
What is the role of the secret key in Flask sessions?
ATo sign the session cookie and prevent tampering
BTo identify the user
CTo store user passwords
DTo encrypt the session data
How do you access session data in Flask?
AUsing the request object
BUsing the session dictionary
CUsing a global variable
DUsing a database query
Which of these is a reason to use server-side session storage?
ATo avoid using cookies
BTo reduce server load
CTo speed up client rendering
DTo store large or sensitive data securely
What happens if you do not set a secret key in Flask when using sessions?
ASessions will work normally
BSession data will be encrypted automatically
CFlask will raise an error when setting session data
DSession data will be stored in the database
Explain how Flask session data storage works and why the secret key is important.
Think about how Flask keeps user info safe between pages.
You got /3 concepts.
    Describe a situation where you would prefer server-side session storage over Flask's default.
    Consider data size and privacy needs.
    You got /3 concepts.