How do I set up a session timeout?

How do I set up a session timeout?

(I’m asking questions using a translator.)

I’m not storing user information in the users collection, but in a separate collection I’ve created.

If the user does nothing for 10 minutes after logging in, I want to log out automatically.

The session API provided by Meteor seems to be available only to clients.

Is there any other way?

안녕하세요!

You could use meteor-idle-watcher:

Detects when a user stops interacting with the page for a specified amount of time (for the purpose of disconnecting them).

I hope that helps.

Check out the various answers to the general question of “how to detect idleness.”

Second answer is vanilla https://stackoverflow.com/a/10126042.

When the timer runs out, you can then simply run Meteor.logout().

I use this to keep a status for my users (e.g ’ User is online’) . You can easily us this for your purpose https://github.com/Konecty/meteor-user-presence