How to set the user login only one at the same time or check user online or not?

I want to set the user can login only one at the same time.
For example, I have “theara” user account to login app. When I login on PC1 (online), so I can’t use the same user to login on PC2 (local network).
How to check user online or solve?

Meteor already has a function for that:

1 Like

Thanks but I don’t know how to use it.

You just do Meteor.logooutOtherClients() on your login! What are you
confused about?

I’m wondering if @theara means “prevent another login” rather than “log others out when I login”?

What the prevent another login?

Hm, it would be interesting and also blocking because due to connectivity or other intermittent issue a client may be known to the server as connected, therefore not allowing the user login at all from other places.

Perhaps one of the presence packages may help with such a scenario.

Thanks for your explain, I will try to fine the presence package.

Could you recommend for the popular package for this?

Take a look at and

I’m not sure there’s a user presence package that scales yet… Both of those look like they wouldn’t handle multiple app instances very well.

The tmeasday package actually uses a dedicated collection to overcome scaling issues.

While it does use a collection, this doesn’t fully mitigate the issues that are caused by scaling to multiple instances… The way it currently works, at start up it starts a function that runs every 5 seconds which checks for outdated presence records, then when the user signs in, it calls an updatePresence method and adds a new record to the presences collection. Then it calls a setInterval which calls a presenceTick method every 5 seconds that updates the collection with a new date… The notion is that when the user disconnects the tick stops, the server doesn’t get a tick so on the next check the connections presence record gets removed.

The problem here is that if an instance stops or dies for any reason, the logic that removes the records for those connections also stops and thus you are stuck with presence records that are no longer valid and the package reports users online that are not any longer…

So perhaps a cleanup function that runs on a wider schedule, perhaps through one of the persisted job runners, could mitigate the problem.

I don’t see this as a scaling issue. It can just as well happen with a single instance, thus it is more like an architecture problem.

I tried the mizzao:user-status with ian:accounts-ui-bootstrap-3.
Status set online is true (auto) when I login. how to check before login?
I thinks that it have problem when the user don’t logout but close the browser.