Flask permanent session: where to define them?

前端 未结 3 516
闹比i
闹比i 2020-12-30 00:00

By default, Flask uses volatile sessions, which means the session cookie is set to expire when browser closes. In order to use permanent sessions, which will use a cookie

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 00:02

    I'm surprised no on has answered this question. It seems like there should be some type of config variable SESSION_PERMANENT = True. But unfortunately there isn't. As you mentioned this is the best way to do it.

    @app.before_request
    def make_session_permanent():
        session.permanent = True
    

提交回复
热议问题