- Run the following flask app (Python 3+, Flask 1.1.0):
from flask import Flask
app = Flask(__name__)
@app.route('/set')
def set_():
return "Set cookie", {'Set-Cookie': 'test=test; Path=/; Max-Age=3600'}
@app.route('/expire')
def expire():
return "Expired cookie", {'Set-Cookie': 'test=test; Path=/; Max-Age=0'}
http --session=./session.json http://localhost:5000/set - The cookie will be set
http --session=./session.json http://localhost:5000/expire - The cookie will not be unset from the session file, check out its contents.
Flask does auto-set Expires when using set_cookie with only max_age, but not all web frameworks do that, and I don't think it is required by the standard.
http --session=./session.json http://localhost:5000/set- The cookie will be sethttp --session=./session.json http://localhost:5000/expire- The cookie will not be unset from the session file, check out its contents.Flask does auto-set
Expireswhen usingset_cookiewith onlymax_age, but not all web frameworks do that, and I don't think it is required by the standard.