how to expire sessions in py4web

51 views
Skip to first unread message

Carlos Hanson

unread,
Mar 4, 2020, 3:03:37 AM3/4/20
to web2py-users
In chapter 4 of the documentation:

By default py4web sessions never expire (unless they contain login information, but that is another story) even if an expiration can be set. 

I see the truth in that statement, since I set the expiration in the session, but my session never expires. 


session
= Session(secret=settings.SESSION_SECRET_KEY, expiration=settings.SESSION_EXPIRATION)


What is the story about sessions containing login information? How do I ensure I am not logged in forever?

Thanks.

Carlos

Massimo Di Pierro

unread,
Mar 21, 2020, 6:27:44 AM3/21/20
to web2py-users
Session and login information are not same. The latter is stored in the former. When you logout it clears the login info in the session but does not clear the session. There is no need. You can of course do session.clear() if you want.

Sessions tells py4web (or web2py) that you are the same user as before. auth tells who you are and what you are authorized to do.

Carlos Hanson

unread,
Mar 21, 2020, 6:54:13 AM3/21/20
to web...@googlegroups.com
Thanks. That makes sense. Unfortunately, I asked the wrong question after trying to figure out the answer myself.

How do I force a logout after some period of time? I thought expiring the session would do that. In web2py, I had to extend the time so my users would stay logged in for a longer period of time. Now I I want to ensure that aren't logged in for too long. 

Thanks. 


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/7FEB2x2pSRM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/858b1d31-2e0a-47b7-bee2-ce91dcc3c9ba%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages