Active Users

kaizenpro used Ask the Experts™

Is there a way to find out which users are logged in to my MVC project. I know how to check that the current user is logged in but I would to find out which other users are logged in too?

Thanks in advance.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Information Services Manager
You could employ a client side javascript to "ping" a handler on your server that the current user is active on ..whatever page.

<script type="text/javascript" src="/Scripts/jquery.min-1.9.0.js"></script>
<script type="text/javascript">
    window.onunload = SetInt();
    function SetInt() {
        window.setInterval(GetID, 5000);

    function GetID() {

        var myvar= jQuery.get("http://" + + "/ActiveUsersHandler.ashx?activeuserinfo=" + $("#activeuserinfo").val(),
        function (data) {

            var ServerResponse = String(data);
            ServerResponse = unescape(ServerResponse)

            //Uncomment for testing server handler response


Open in new window

I use this simple script above in my Call Center CRM.. so my phone system knows whether or not to send the call+data to the "available" user.
What this basically does.. is request the resource "ActiveUsersHandler.ashx", every five seconds.. with a parameter containing the contents of the hidden field "#activeuserinfo".. which you would fill with the user id, the page they are on, and whatever else you want as long as you can parse it.  The handler should be programmed to  send this information to a SQL table, or other storage method.. which you will also store the timestamp.  Then you simply query the table or other storage method you used..for entries with timestamps  within the last 5 seconds.. maybe add an additional second or two.. to account for read/write delay.  With this code, you could also control who stays logged in.. if you process the  response from your handler to redirect them to a logout page for example.  You can log their visits to every page, how long they stayed, ..if they are "idle".. all sorts of things depending on your creativity and skill in programming with jQuery, java, and handlers.


Thanks Ron,

Great solution, i'll put it in to place.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial