Invalidate an old session in Flask

后端 未结 4 1762
名媛妹妹
名媛妹妹 2020-12-13 10:29

How do I create a new clean session and invalidate the current one in Flask?

Do I use make_null_session() or open_session()?

4条回答
  •  失恋的感觉
    2020-12-13 10:36

    If you use default flask sessions and set the app.permanent_session_lifetime, then the session will not work if a user tries to replay the same session as long as the session has expired.If you look at the source code for open_session, there is line:

    max_age = total_seconds(app.permanent_session_lifetime)
    try:            
        data = s.loads(val, max_age=max_age)
        return self.session_class(data)
        except BadSignature:
            return self.session_class()
    

提交回复
热议问题