You have return the response after set the cookie.
@app.route('/')
def index():
resp = make_response(render_template(...))
resp.set_cookie('somecookiename', 'I am cookie')
return resp
This way cookie will generate in your browser but you can get this cookie in next request.
@app.route('/get-cookie/')
def get_cookie():
username = request.cookies.get('somecookiename')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…