python服务器:
from flask import Flask,request,make_response app = Flask(__name__) @app.route('/') def index(): resp = make_response("123456abc") resp.set_cookie("001a","001b") resp.set_cookie("002c","002d",max_age=500) print(request.headers) print('-----------------------------------------------------------------') print(request.cookies) print('+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') return resp @app.route('/001') def index01(): resp = make_response("123") print(request.headers.get("Host")) print(request.headers) print('-----------------------------------------------------------------') print(request.cookies) print('+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
print(request.cookies.get("001a"))
print(request.cookies.get("002c"))
return resp if __name__ == '__main__': app.run(debug=True)
web第一次访问:
web第一次访问,python打印:
web第二次访问:
web第二次访问,python打印: