Who is in the Pylons

I currently have a Pylons application working with basic user system setup. I want to try to create a widget that shows the users who are currently logged in to the website. I'm not sure how I should handle this; I'm not sure if active pylons sessions are based on whether the user is really on the web application page or not, so I'm looking for some ideas on how I can work with what I already have in order to accomplish this.

+7
web-applications session pylons
source share
1 answer

There are several ways to do this, depending on how accurate you are.

The easiest and first way to do this is to use memecached or a permanent store to track users, and the last time they hit the page. Think about who got on the page for X minutes to log in if they did not "log out". If you just refresh db on every page hit or refresh memcached (or faster db) then request it for sessions in the last minute.

Secondly, but more intensively on your server, put Javascript on every page that gets to your site’s special URL every XX seconds / minutes to indicate that the user is logged in. Write it down and use this account. This has the advantage that your JS can maintain a counter on the current page in real time. Although polling can be expensive on your server.

Or, thirdly, use the Comet style system, say, with Orbited, and while the user is on the page connected to the server, the connection will be open and you can track how many open sessions you have. Orbited can handle about 10 thousand open connections at a time on one server, which, I believe.

I would recommend the first type, since it requires the least additional overhead / setup and handles a fairly common case. If you use real-time chat where you need better accuracy, consider one of the other two.

+11
source share

All Articles