I am working on a web app that uses Web2py. My auth_user table has a username field. The problem that I am facing is when I update the username of a user, auth.user.username keeps returning the old value until the user logs out and login again.
Moreover sometimes I notice that even on making a fresh db query for the given user id it returns the obsolete user name. Why does this happen?
auth.useris stored in the session (along with some other auth related data). This avoids having to do a db query for the user data on every request. Therefore, updating the record in the db does not update theauth.userobject in the session. If the user updates their own profile using the built inauth.profile()functionality, thenauth.userwill automatically get updated. Otherwise, you will have to update it yourself: