Reset cookie expiration time in bulb

I am using the Python flash framework. I use sessions in my application. For my application called main , I have the parameter main.permanent_session_lifetime = timedelta(days=5) , so that the user remains on the system for 5 days after logging in. But even an active user will log out after 5 days. I would like the expiration time to reset every time they visit the site, so you only log out after 5 days of inactivity . Most sites work this way. How to do it with Flask?

+12
python flask session
Nov 04 '13 at 1:45
source share
2 answers

You can update the session for the client for each request using the @before_request handler.

Try the following:

 @app.before_request def func(): session.modified = True 
+19
Nov 05 '13 at 17:46
source share

Should be enough with:

 from datetime import timedelta # User will be logout after this time of inactivity PERMANENT_SESSION_LIFETIME = timedelta(minutes=30) SESSION_REFRESH_EACH_REQUEST = True 

https://flask.palletsprojects.com/en/1.1.x/config/

0
Sep 05 '19 at 10:18
source share



All Articles