[英]How can I cycle through sessions in flask?
I have been wondering how I could cycle through sessions.我一直想知道如何循环浏览会话。 I want to make a system that clears all sessions with the id variable set to the current session id upon going to a specific URL.我想创建一个系统,在转到特定的 URL 时清除所有会话,其中 id 变量设置为当前 session id。 How can I do that?我怎样才能做到这一点?
In my projects (not in production, of course) I used something like:在我的项目中(当然不是在生产中)我使用了类似的东西:
@app.route('/clear/')
def clear_session():
session.clear()
return redirect('/')
To clear the flask session you can use session.clear()
要清除 flask session 您可以使用session.clear()
from flask import session
session.clear()
Or you can use session.pop()
in a for loop.或者您可以在 for 循环中使用session.pop()
。 Unfortunatelly i don't know so muxh about this.不幸的是,我对此一无所知。
But, for more questions about this, you can read this other question on clearing the sessions: How do I clear a flask session?但是,有关此问题的更多问题,您可以阅读有关清除会话的其他问题: 如何清除 flask session?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.