标签:spl tor cti decorator text comment mil isp com
from flask import Flask,Response
app = Flask(__name__)
@app.route(‘/index‘)
def index():
response = Response("设置cookie")
response.set_cookie(‘username‘,‘sfencs‘)
return response
if __name__ == ‘__main__‘:
app.run()
username= request.cookies.get(‘username‘)
response.delete_cookie(‘username‘)
使用session需要设置SECRET_KEY
from flask import Flask,Response,session
app = Flask(__name__)
app.config[‘SECRET_KEY‘] = ‘asdadasd’
@app.route(‘/index‘)
def index():
session[‘username‘] = ‘sfencs‘
return ‘session‘
if __name__ == ‘__main__‘:
app.run()
username = session.get(‘username‘)
session.pop(‘username‘)
session.clear() #删除所有session
标签:spl tor cti decorator text comment mil isp com
原文地址:https://www.cnblogs.com/sfencs-hcy/p/10787613.html