Design the presence layer of a chat product: the green dot. Online clients ping a heartbeat on a timer, and profile cards, conversation headers, and buddy lists read status back out.
A user is online because their device keeps saying so, and offline the moment it stops saying it.