Login details are stored in session.auth, including the expiration in
session.auth.expiration. So, you could do something like:
def after_login(form):
if 'special_group' in auth.user_groups.values():
session.auth.expiration = 60 * 60 * 24
auth.settings.login_onaccept.append(after_login)
Anthony
On Thursday, August 6, 2015 at 10:04:49 AM UTC-4, Eric wrote:
>
> Hi,
>
> How can I change the session expiration length after someone has loggedin?
> I've found the setting auth.settings.expiration, but that only works when I
> place it in the db.py (or somewhere before I call the (bare)login
> function). Trouble is that I only know the rights of the user after login,
> so I can only update the session length after login. The reason why I want
> to change it session length? Users with specific rights that are coming
> from a 'safe' (IP) location are allowed to have longer session length than
> the 'unsafe' user.
>
> The only way that I've found to get this task done is by manipulating
> the expiration the session_data blob / pickle right after the user was
> loggedin... This works, but seems to me that it's not very Web2Py like ;)
>
> Is there another way to change it? Or is this the right (or best) way to
> do it?
>
> Thanks for the reaction!
>
>
--
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 the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.