0
0
Flaskframework~5 mins

How cookies work in HTTP in Flask - Quick Revision & Summary

Choose your learning style9 modes available
Recall & Review
beginner
What is a cookie in the context of HTTP?
A cookie is a small piece of data sent from a website and stored on the user's browser. It helps remember information about the user between requests.
Click to reveal answer
beginner
How does a server send a cookie to a client in HTTP?
The server sends a cookie using the 'Set-Cookie' header in the HTTP response. The browser then stores this cookie.
Click to reveal answer
beginner
How does the browser send cookies back to the server?
The browser includes stored cookies in the 'Cookie' header of subsequent HTTP requests to the same server.
Click to reveal answer
intermediate
In Flask, how do you set a cookie in a response?
Use the 'set_cookie' method on the response object, for example: response.set_cookie('key', 'value').
Click to reveal answer
intermediate
What are some common cookie attributes that control cookie behavior?
Attributes include 'Expires' or 'Max-Age' (lifetime), 'Path' (URL scope), 'Domain' (which domains can access), 'Secure' (only over HTTPS), and 'HttpOnly' (not accessible by JavaScript).
Click to reveal answer
Which HTTP header does the server use to send a cookie to the client?
AAuthorization
BCookie
CSet-Cookie
DContent-Type
When the browser sends cookies back to the server, which header is used?
ACookie
BUser-Agent
CSet-Cookie
DReferer
In Flask, which method sets a cookie on the response object?
Aresponse.set_cookie()
Brequest.set_cookie()
Cresponse.get_cookie()
Drequest.get_cookie()
What does the 'HttpOnly' cookie attribute do?
AMakes cookie accessible only via JavaScript
BPrevents cookie from being sent over HTTPS
CDeletes the cookie immediately
DPrevents JavaScript access to the cookie
Which cookie attribute restricts the cookie to HTTPS connections only?
AHttpOnly
BSecure
CDomain
DPath
Explain how cookies are created, stored, and sent back in HTTP communication.
Think about the journey of a cookie from server to browser and back.
You got /3 concepts.
    Describe how to set and read cookies in a Flask web application.
    Consider Flask's request and response objects.
    You got /3 concepts.