Active Users


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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ron MalmsteadInformation Services ManagerCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kaizenproAuthor Commented:
Thanks Ron,

Great solution, i'll put it in to place.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.