I have a python flask app with login module implemented using extension python flask. In my login method, I have set below
def login():
.......
.......
session.permanent = True
app.permanent_session_lifetime = datetime.timedelta(minutes=3)
......
......
This code sets my session cookie to 3 minutes as expected.
What's happening right now is, after 3 minutes, the page is still active and sending GET requests and POST request even the session is expired. What I want is after session is expired the page to default to login page.
Does flask-login provides this functionality out of box? Any suggestion would be helpful
Thanks
Using flask-login, do this, it will automatically redirects to login page.
@app.before_request
def before_request():
flask.session.permanent = True
app.permanent_session_lifetime = datetime.timedelta(seconds=30)
flask.session.modified = True
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.