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?
✗ Incorrect
The server uses the 'Set-Cookie' header to send cookies to the client.
When the browser sends cookies back to the server, which header is used?
✗ Incorrect
The browser sends cookies in the 'Cookie' header with HTTP requests.
In Flask, which method sets a cookie on the response object?
✗ Incorrect
You use response.set_cookie() to add a cookie to the HTTP response in Flask.
What does the 'HttpOnly' cookie attribute do?
✗ Incorrect
'HttpOnly' makes the cookie inaccessible to JavaScript, improving security.
Which cookie attribute restricts the cookie to HTTPS connections only?
✗ Incorrect
The 'Secure' attribute ensures the cookie is sent only over HTTPS.
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.