Hi,
Is there a built-in feature that prevent users from logining more than one browser/device.
If the users already logined, they cannot login using other browsers/devices.
Thank you
Hi,
Is there a built-in feature that prevent users from logining more than one browser/device.
If the users already logined, they cannot login using other browsers/devices.
Thank you
Not that I know of.
The problem with web apps is that you can never be sure a user is still logged in, as often just closing the browser gives no indication you’ve gone away. This makes knowing for certain if a user is actually logged in at any point in time rather difficult.
You could set up a timer on the client that calls a server function every x minutes, which in turn updates a “last_pinged” column in your users table.
When that user attempts to log in, you could check the “last_pinged” time to see if it is older than x minutes. If it is, you can assume the other login to be dead, and replace it with the new one. If it is within the time, you could display “You appear to be logged in elsewhere. Try again in X minutes”.
Does that make sense?
It makes sense. I’ve implemented something similar.
Thanks, I guess I need to make the requirement clearer.
When user login the app with “remember me” is ticked, next tine users don’t need to login again.
Some apps that I know can force users log out when the users login from other devices/browsers.
This means that if the users online in the old devices/browsers, they are forced to logout and login again, if the users is offline, whenever they access the app, they need to login again.
In other words, how the Anvil-made apps force the users log out? Generally, session/cookies seems to be used but I don’t know exactly how to do it.
Logging the current user out is actually much simpler than that: anvil.users.logout()
.
Based on your suggestion, I made a slightly different solution, thank you