Message Boards

How to fetch all current loggedin users

Madhu Chandrappa, modified 9 Years ago.

How to fetch all current loggedin users

New Member Posts: 7 Join Date: 1/14/15 Recent Posts
How to fetch all current loggedin users
thumbnail
Jitendra Rajput, modified 9 Years ago.

RE: How to fetch all current loggedin users

Liferay Master Posts: 875 Join Date: 1/7/11 Recent Posts
Set below property to true to get list of live users. Once you enable this property you will see live data under monitoring tab in control panel.


##
## Live Users
##

    #
    # Set this to true to enable tracking via Live Users.
    #
    live.users.enabled=true


Thank you,
Jitendra
Madhu Chandrappa, modified 9 Years ago.

RE: How to fetch all current loggedin users

New Member Posts: 7 Join Date: 1/14/15 Recent Posts
Thanks Jitendra

but how to display it in jsp page..

Thanks
Madhu
thumbnail
Jitendra Rajput, modified 9 Years ago.

RE: How to fetch all current loggedin users

Liferay Master Posts: 875 Join Date: 1/7/11 Recent Posts
After enabling live user property in portal-ext you can use below API to get list of logged in users.

LiveUsers.getSessionUsers(long companyId)


Note : LiveUsers class is in portal-impl you can not use directly in your plugin . You can use PortalClassInvoker to access portal-impl classes.


Thank you,
Jitendra
Madhu Chandrappa, modified 9 Years ago.

RE: How to fetch all current loggedin users

New Member Posts: 7 Join Date: 1/14/15 Recent Posts
hi
am newer to liferay. so am not getting u. what is companyId and am getting companyId as NULL.
thumbnail
David H Nebinger, modified 9 Years ago.

RE: How to fetch all current loggedin users

Liferay Legend Posts: 14919 Join Date: 9/2/06 Recent Posts
It won't matter if you're using Liferay in a cluster. His code will only give you the users logged into a given node, not the entire cluster. That list does not exist.

If you don't know the companyId thing, then you're probably too green as yet to be accessing the portal core to grab the list and display it within a portlet. All data stored in Liferay is keyed off of a company id (to support virtual hosting). You need to know what company id you're using so you can get the list of it's locally logged in users.

But honestly I can tell you that this is not a path that is going to give you what you want. There is no current list of logged in users because users do not have to log out (they can just close their browsers, their computer/browser can crash abruptly stopping any communication, network links can drop i.e. you take your phone out of cell range, ...).

Whatever list you think you're going to get and whatever you expect to do with it, well I can tell you that 99% of the time it will be incomplete and inaccurate.