Peter De Berdt wrote:
We have a prospect who’s asking us to provide a price for a certain
number of concurrent users for our application (i.e. they can have 50
user accounts, but only 20 users are logged in at the same time).
Does anyone have experience on how to handle this? Maybe by getting
the number of active sessions?
Up till now, we have always uses an unlimited user license, but in
this case the upselling argument is just too tempting to let go of
(and we can cut down on the initial price).
Peter De Berdt
When a user logs in, you could store Time.now in a field on the user
record in the db. When they log out, set the time to nil. When another
user is logging in, the login script should check to see how many users
are marked as “logged in”, going back a certain amount of time. That way
if someone happens to close their browser without logging off, you won’t
have a zombie user attached to the system.
The only other thing you’d need to make this work is to update the last
touched time on the user throughout their use, so that someone already
logged in can’t become “logged out” just by using the site for 30
minutes or whatever. Maybe stick an application-wide before_filter on