使用flaskflash时,Flask会话不工作

2024-05-29 04:59:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试一种简单的登录和注销方法,当您这样做时,它会用一个flash()来迎接您。但由于某些原因,当我尝试注销并使用flash时,session.pop()不会执行任何操作

@app.route("/logout")
def logout():
    session.pop("_usern", None) #For some reason I don't understand it does not pop _usern if I use flash. 
    flash("Goodbye!", 'info')
    return redirect(url_for("index"))

我注意到在使用flash()之后,调试器在session.pop()中返回<FileSystemSession {'_flashes': [('info', 'Goodbye!')]}>而不是<FileSystemSession {'_usern': '******'}>作为值


Tags: 方法infononeappforsessiondef原因

热门问题