Reputation: 580
I want to show the remaining session time on top of the page of my website.
I have used the following code to set session time in my __init.py file
from datetime import timedelta
d=timedelta(minutes=5)
app.config['PERMANENT_SESSION_LIFETIME']=d
I want to get the remaining session time ? so that i could show it on screen
is there any way to do it in FLASK ?
Upvotes: 0
Views: 298
Reputation: 8273
from datetime import datetime ,timedelta
start_time=datetime.now()
d=timedelta(minutes=5)
time_left=d-(datetime.now()-start_time)
time_left.total_seconds()/60
Upvotes: 1