0
0
Flaskframework~5 mins

Setting and reading cookies in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a cookie in web development?
A cookie is a small piece of data stored on the user's browser. It helps websites remember information like login status or preferences.
Click to reveal answer
beginner
How do you set a cookie in Flask?
You set a cookie by creating a response object and using its set_cookie() method with a key and value.
Click to reveal answer
beginner
How do you read a cookie value in Flask?
You read a cookie from the request.cookies dictionary using the cookie's key name.
Click to reveal answer
intermediate
What is the purpose of the max_age parameter when setting a cookie?
It sets how long the cookie will last in seconds before it expires and is deleted from the browser.
Click to reveal answer
intermediate
Why should you use cookies carefully in web apps?
Because cookies store data on the user's device, they can affect privacy and security. Sensitive data should not be stored in cookies.
Click to reveal answer
Which Flask object do you use to set a cookie?
AApp object
BResponse object
CSession object
DRequest object
How do you access cookies sent by the browser in Flask?
Arequest.cookies
Bresponse.cookies
Csession.cookies
Dapp.cookies
What does the max_age parameter control when setting a cookie?
ACookie size limit
BCookie encryption
CCookie domain
DCookie expiration time
Which of these is NOT a good practice when using cookies?
ATracking user sessions
BStoring user preferences
CStoring sensitive passwords
DSetting cookie expiration
What type of data structure is request.cookies in Flask?
ADictionary
BList
CTuple
DSet
Explain how to set and read cookies in a Flask web application.
Think about how the server sends cookies and how it reads them back from the browser.
You got /4 concepts.
    Describe why cookie expiration is important and how to control it in Flask.
    Consider what happens if cookies never expire.
    You got /4 concepts.