[Flask] Expiring login sessions
Matt Shields
matt at mattshields.org
Mon Sep 14 14:46:46 CEST 2015
Below is what I had put in when I was building the login and sessions.
I've tried setting the app.permanent_session_lifetime to a specific amount
of time so that the user will get logged out and it doesn't seem to work.
Also, besides logging them out after a specific amount of time, I'd like to
have them logged out if they close their browser
29 @app.before_request
30 def before_request():
31 g.permission = config.permission_problem()
32 g.current_time = datetime.datetime.now().strftime('%Y-%m-%d
%H:%M:%S')
33 session.permanent = True
34 app.permanent_session_lifetime = datetime.timedelta(minutes=60)
35
36 if current_user.is_authenticated():
37 user = User.query.filter_by(email=current_user.email).first()
38 user.current_login_at = datetime.datetime.now()
39 db.session.commit()
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20150914/1a510835/attachment.html>
More information about the Flask
mailing list