[Flask] Expiring login sessions
Minglangjun Li
liminglangjun at gmail.com
Tue Sep 15 02:59:03 CEST 2015
Have you tried to set it in a config file?
On Mon, Sep 14, 2015 at 12:46 PM, Matt Shields <matt at mattshields.org> wrote:
> 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
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
>
--
Best,
Minglangjun Li
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20150915/31a7a80a/attachment.html>
More information about the Flask
mailing list