# How to check the live users

**URL:** <https://www.ruby-forum.com/t/how-to-check-the-live-users/129087>\
**Category:** Rails\
**Created:** [February 14, 2008, 4:42am UTC](https://www.ruby-forum.com/t/how-to-check-the-live-users/129087 "2008-02-14T04:42:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavanagrawal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@pavanagrawal](https://www.ruby-forum.com/u/pavanagrawal)\
**Post date:** [February 14, 2008, 4:42am UTC](https://www.ruby-forum.com/t/how-to-check-the-live-users/129087/1 "2008-02-14T04:42:46Z")

</div>

Hi All,  
Since few days I stuck in a question that how to find logged  
in users of my application. I am using db session store. can any buddy  
help for this.

Thanks a lot in advance.

Regards,  
Pavan

---

<div class="post-metadata">

**Author:** ![pavanagrawal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@pavanagrawal](https://www.ruby-forum.com/u/pavanagrawal)\
**Post date:** [February 14, 2008, 1:50pm UTC](https://www.ruby-forum.com/t/how-to-check-the-live-users/129087/2 "2008-02-14T13:50:01Z")

</div>

I would use a before\_filter on any action that a user might take which  
updates a timestamp field in a separate model. Then, to find out who  
is online, you could search that model for rows that have updated in  
the last few minutes.

Robin

On Feb 14, 3:42 am, “Pavan A. @ Rails” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![pavanagrawal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@pavanagrawal](https://www.ruby-forum.com/u/pavanagrawal)\
**Post date:** [February 14, 2008, 2:02pm UTC](https://www.ruby-forum.com/t/how-to-check-the-live-users/129087/3 "2008-02-14T14:02:09Z")

</div>

The web uses a connectionless protocol and you cannot force people to  
log out. They can just disconnect. You could record the time of  
login and logout but that wouldn’t be quite right, because you can’t  
distinguish between someone has shutting down their machine and going  
away from them having a momentary disconnect.

You could expire their session (their login) if X minutes elapsed and  
they didn’t do anything. But then you’d have to record the time in  
the database each time they did something.

F
