Complete the code to set a cookie named 'remember_token' with the user's token.
response.set_cookie('remember_token', [1])
The cookie should store the user's unique token to remember them.
Complete the code to check if the 'remember_token' cookie exists in the request.
if [1] in request.cookies:
We check if the cookie named 'remember_token' is present in the request cookies.
Fix the error in this code that tries to set a cookie with expiration for 'remember me' functionality.
response.set_cookie('remember_token', token, max_age=[1])
The cookie should last about 30 days, so max_age should be 60*60*24*30 seconds.
Fill both blanks to retrieve the token from the cookie and verify the user.
token = request.cookies.get([1]) user = User.query.filter_by([2]=token).first()
We get the 'remember_token' cookie and use the variable 'token' to query the user.
Fill all three blanks to set a secure, HTTP-only cookie with a 7-day expiration.
response.set_cookie([1], [2], max_age=[3], secure=True, httponly=True)
The cookie name is 'remember_token', the value is the user's token, and max_age is 7 days in seconds.