标签:ram ams imp ssi fun sda cookie 删除 code
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
标签:ram ams imp ssi fun sda cookie 删除 code
原文地址:https://www.cnblogs.com/Moodsfeelings/p/11809906.html