I set cookies with the code suggested in the docs:
from flask import make_response
@app.route('/')
def index():
resp = make_response(render_template(...))
resp.set_cookie('username', 'the username')
return resp
But how do I remove them? There is no remove_cookie method. I tried:
if request.cookies.get('sessionID');
request.cookies.pop('sessionID', None)
but it turns out that the request.cookies object is immutable. What do I do?
There’s no HTTP header for deleting a cookie. Traditionally you just set the cookie to a dummy value with an expiration date in the past, so it immediately expires.
This will set the session id cookie to an empty string that expires at unixtime
0, which is almost certainly in the past.