Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
sarika kotha
liferay method to get all session ids
19 gennaio 2012 4.01
Risposta

sarika kotha

Punteggio: New Member

Messaggi: 8

Data di Iscrizione: 19 gennaio 2012

Messaggi recenti

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
David H Nebinger
RE: liferay method to get all session ids
19 gennaio 2012 6.10
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11795

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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
RE: liferay method to get all session ids
20 gennaio 2012 0.27
Risposta

sarika kotha

Punteggio: New Member

Messaggi: 8

Data di Iscrizione: 19 gennaio 2012

Messaggi recenti

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
Amos Fong
RE: liferay method to get all session ids
20 gennaio 2012 0.39
Risposta

Amos Fong

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 1913

Data di Iscrizione: 7 ottobre 2008

Messaggi recenti

Hi,

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

1##
2## Live Users
3##
4
5    #
6    # Set this to true to enable tracking via Live Users.
7    #
8    live.users.enabled=false


You can look at the LiveUsers class to see how to retrieve the info.
David H Nebinger
RE: liferay method to get all session ids
20 gennaio 2012 5.25
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11795

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

Well, stored in memory, yes that property needs to be set, but it's never stored in the database.
sarika kotha
RE: liferay method to get all session ids
22 gennaio 2012 22.40
Risposta

sarika kotha

Punteggio: New Member

Messaggi: 8

Data di Iscrizione: 19 gennaio 2012

Messaggi recenti

hi thank you for the information, but where should i change that property.please inform me.


thanks in advance

sarika
Sandeep Nair
RE: liferay method to get all session ids
22 gennaio 2012 22.46
Risposta

Sandeep Nair

Punteggio: Liferay Legend

Messaggi: 1721

Data di Iscrizione: 5 novembre 2008

Messaggi recenti

It should be in portal-ext.properties where you specify you db related properties.

Regards,
Sandeep
sarika kotha
RE: liferay method to get all session ids
23 gennaio 2012 2.58
Risposta

sarika kotha

Punteggio: New Member

Messaggi: 8

Data di Iscrizione: 19 gennaio 2012

Messaggi recenti

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
David H Nebinger
RE: liferay method to get all session ids
23 gennaio 2012 5.27
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11795

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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
RE: liferay method to get all session ids
24 gennaio 2012 3.52
Risposta

sarika kotha

Punteggio: New Member

Messaggi: 8

Data di Iscrizione: 19 gennaio 2012

Messaggi recenti

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
MICHAIL MOUDATSOS
RE: liferay method to get all session ids
4 maggio 2012 4.34
Risposta

MICHAIL MOUDATSOS

Punteggio: Regular Member

Messaggi: 110

Data di Iscrizione: 4 ottobre 2011

Messaggi recenti

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
RE: liferay method to get all session ids
4 maggio 2012 4.34
Risposta

MICHAIL MOUDATSOS

Punteggio: Regular Member

Messaggi: 110

Data di Iscrizione: 4 ottobre 2011

Messaggi recenti

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
1<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?
fouad fouad
RE: liferay method to get all session ids
15 gennaio 2015 0.43
Risposta

fouad fouad

Punteggio: Junior Member

Messaggi: 28

Data di Iscrizione: 8 agosto 2014

Messaggi recenti

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