Foren

liferay method to get all session ids

sarika kotha, geändert vor 12 Jahren.

liferay method to get all session ids

New Member Beiträge: 8 Beitrittsdatum: 19.01.12 Neueste Beiträge
hi friends,
please help me in finding this,i am developing a portlet which needs all the users session ids who are logged in into liferay.is there any method in liferay api please send me the syntax,i will be very thankful.


thanks in advance
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: liferay method to get all session ids

Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
That info is not persisted, it is in memory of Liferay.

I don't think the list is exposed by default.

Fortunately the Liferay source is available so you can pull up the code for the Monitoring control panel and see how they do it. You may have to override some Liferay code to make it available outside of the core Liferay system, but it should certainly be doable.
sarika kotha, geändert vor 12 Jahren.

RE: liferay method to get all session ids

New Member Beiträge: 8 Beitrittsdatum: 19.01.12 Neueste Beiträge
David H Nebinger:
That info is not persisted, it is in memory of Liferay.

I don't think the list is exposed by default.

Fortunately the Liferay source is available so you can pull up the code for the Monitoring control panel and see how they do it. You may have to override some Liferay code to make it available outside of the core Liferay system, but it should certainly be doable.



hi david,

thank you very much for u r reply,but i have gone through some of the source of liferay from liferay api's,but i am very new to it so i need some help which classes to look ,so i cAN FIND THE SOLUTION.

thanks in advance
thumbnail
Amos Fong, geändert vor 12 Jahren.

RE: liferay method to get all session ids

Liferay Legend Beiträge: 2047 Beitrittsdatum: 07.10.08 Neueste Beiträge
Hi,

I believe session info is not stored unless you turn on monitoring via live users.

##
## Live Users
##

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


You can look at the LiveUsers class to see how to retrieve the info.
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: liferay method to get all session ids

Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
Well, stored in memory, yes that property needs to be set, but it's never stored in the database.
MICHAIL MOUDATSOS, geändert vor 11 Jahren.

RE: liferay method to get all session ids

Regular Member Beiträge: 110 Beitrittsdatum: 04.10.11 Neueste Beiträge
David H Nebinger:
Well, stored in memory, yes that property needs to be set, but it's never stored in the database.

However, this information (i.e. userId-sessionId, and the session itself) is not lost even after a server restart, which means that this information is somehow persisted between app server restarts, probably by serialization. Could one have access to this serialized information? It would be nice if one wanted to implement his/her own SessionListener.

To take this one step further, there probably already exists an implemented SessionListener in Liferay code. It should probably be located in portal-impl.jar, whose API can not be directly accessed by a portlet's code. However, as it is mentioned in this conversation, an (awsome, in my opoinion) idea, which is simple yet I haven't read anywhere else, is to expose the desired functionality throuth the implementation of an ext-plugin (with all the consequent implications).

So, does anyone know where to look for Liferay SessionListener? Is it a good idea to use it, by exposing it through an ext-plugin?

Thank you for your time

PS For those wondering, I want a session listener in order to implement the old auth.simultaneous.logins functionality. I want to invalidate the session, let say A, of the logged in user when the same user re-loggins, so I need that session A! If application server restarts, I could use an application.startup.events, where I would brutally kill all sessions just in case ( emoticon ) but I wanted a more elegant approach and since liferay seems to handle sessions properly when application server restarts, why wouldn't I use its functionality, rather than trying to re-invent the wheel???
MICHAIL MOUDATSOS, geändert vor 11 Jahren.

RE: liferay method to get all session ids

Regular Member Beiträge: 110 Beitrittsdatum: 04.10.11 Neueste Beiträge
Well, it seems that session persistence is a container's job, so Liferay has nothing to do with it. I suppose there's no way, or no easy way, to access this info. On the other hand, one can disable persistent sessions across app server restarts in tomcat by uncommenting
<manager pathname="" />
in $CATALINA_HOME/conf/Context.xml

As for the session listener - part of the question, the only thing I could find was com.liferay.portal.kernel.servlet.PortletSessionTracker in portal-service.jar, nevertheless there's no public method to use to get any session. It contains a private Map<String, Set<HttpSession>> of all sessions. So using an ext-plugin maybe one could give access to this map and start messing up with it... I just used the ServletContext to store userId-HttpSession pairs in a map, which means I will be forced to disable persistent sessions across app server restarts, otherwise my implementation will brake since ServletContext is destroyed (and since I've yet to think of a good way to persist the HttpSession object and retrieve it at ServletContext creation - does anyone have? emoticon )

Can anyone confirm the above statements?
sarika kotha, geändert vor 12 Jahren.

RE: liferay method to get all session ids

New Member Beiträge: 8 Beitrittsdatum: 19.01.12 Neueste Beiträge
hi thank you for the information, but where should i change that property.please inform me.


thanks in advance

sarika
thumbnail
Sandeep Nair, geändert vor 12 Jahren.

RE: liferay method to get all session ids

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
It should be in portal-ext.properties where you specify you db related properties.

Regards,
Sandeep
sarika kotha, geändert vor 12 Jahren.

RE: liferay method to get all session ids

New Member Beiträge: 8 Beitrittsdatum: 19.01.12 Neueste Beiträge
Sandeep Nair:
It should be in portal-ext.properties where you specify you db related properties.

Regards,
Sandeep



thank you,sandeep but actually my plan is to retrieve all the session ids of liferay users.my requirement is to get all the session ids of liferay users and display those session ids of users who will be using my own portlets,deployed in liferay.

thanks in advance
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: liferay method to get all session ids

Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
Well turning on the property enables Liferay monitoring.

Cloning from the monitoring page will show you how to access session ids.

From there, however, you're done. You can see the session ids, but not know what the users are doing.

If you want to see who's using your portlets, you probably want more of an audit trail type of function.
sarika kotha, geändert vor 12 Jahren.

RE: liferay method to get all session ids

New Member Beiträge: 8 Beitrittsdatum: 19.01.12 Neueste Beiträge
David H Nebinger:
Well turning on the property enables Liferay monitoring.

Cloning from the monitoring page will show you how to access session ids.

From there, however, you're done. You can see the session ids, but not know what the users are doing.

If you want to see who's using your portlets, you probably want more of an audit trail type of function.



Thank you david,
i have changed the properties file i.e..portal-ext properties but how should i track them can u explain me in detail.as i am very new to all these coding,but i am trying hard to do all these.i also need a clarification that whether is this possible.getting all the session ids of users in liferay and sending them to my portlets jsp page,and display only those ids of users who are using my portlets context.

thanks in advance
fouad fouad, geändert vor 9 Jahren.

RE: liferay method to get all session ids

Junior Member Beiträge: 28 Beitrittsdatum: 08.08.14 Neueste Beiträge
sarika kotha:
David H Nebinger:
Well turning on the property enables Liferay monitoring.

Cloning from the monitoring page will show you how to access session ids.

From there, however, you're done. You can see the session ids, but not know what the users are doing.

If you want to see who's using your portlets, you probably want more of an audit trail type of function.



Thank you david,
i have changed the properties file i.e..portal-ext properties but how should i track them can u explain me in detail.as i am very new to all these coding,but i am trying hard to do all these.i also need a clarification that whether is this possible.getting all the session ids of users in liferay and sending them to my portlets jsp page,and display only those ids of users who are using my portlets context.

thanks in advance



hello man,
did u manage to do ur requirement, if yes please can u share it , because i need the same requirement . thank you emoticon