#session 使用
app.secret_key = "dsada12212132dsad1232113"
app.config['PERMANENT_SESSION_LIFETIME']=timedelta(days=7000) #设置session的保存时间。
@app.route("/session",methods=["GET","POST"])
def sess():
print(session.get('user_name'))
if request.method == "POST":
session.permanent = True #默认session的时间持续31天,设置后可以自定义过期时间
username = request.form.get("username")
session['user_name'] = "dsadasd12dsada1232132123213113213123dsadasd" #设置
return session.get('user_name') #返回session 当前值 #删除session session.pop('username') #清除session session.clear()
return render_template("session.html")
app.run(debug=True,host="127.0.0.1",port=80)