掲示板

Can anyone please help me with implementing session listener.

thumbnail
10年前 に Rahul Saraswat によって更新されました。

Can anyone please help me with implementing session listener.

Junior Member 投稿: 62 参加年月日: 13/02/26 最新の投稿
I implemented a session listener by different ways, but the overridden method sessionCreated() is being called. The method sessionDestroyed() is not being called. I tried closing the browser, clearing the browser data and invalidating the session in the PortletController, but it is not being called. Can any one please help????????

I tried implementing HttpSessionListener, extending PortletSessionListenerManager and extending PortletSessionTracker but none of them got a call to the method sessionDestroyed.

Below is the one of the sample codes that I tried :

public class BrowserListener implements HttpSessionListener {

private static Log logger = LogFactoryUtil.getLog(BrowserListener.class);

@Override
public void sessionCreated(HttpSessionEvent se) {
// TODO Auto-generated method stub
HttpSession session = se.getSession();
logger.info("Session created...." + session.getCreationTime());
}

@Override
public void sessionDestroyed(HttpSessionEvent se) {

HttpSession session = se.getSession();

// TODO Auto-generated method stub
logger.info("Session destroyed...." + session.getId());
}
}
It is very urgent can anyone please help.... Thanks in advance.!!!!

Thanks & Regards
Rahul Saraswat
thumbnail
10年前 に David H Nebinger によって更新されました。

RE: Can anyone please help me with implementing session listener.

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Note that although your plugin is bundled and shipped as a war doesn't mean that it is used as a servlet w/ a session.
thumbnail
10年前 に Rahul Saraswat によって更新されました。

RE: Can anyone please help me with implementing session listener.

Junior Member 投稿: 62 参加年月日: 13/02/26 最新の投稿
David H Nebinger:
Note that although your plugin is bundled and shipped as a war doesn't mean that it is used as a servlet w/ a session.


So what shall I do to track the session or you want to say that there is no way to track it?
thumbnail
10年前 に David H Nebinger によって更新されました。

RE: Can anyone please help me with implementing session listener.

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
A portlet session is not the same as a servlet session. You cannot track users by trying to do that. You can use a login/logout action pair, registered with the portal, but logout tracking is very unreliable.

A user can close their browser (not log out).

A user can type in another url or a bookmark or a link that would take them away from the portal, also no logout.

If you're on a cluster, then tracking login/logout is even that much harder.
8年前 に Naveen Kulkarni によって更新されました。

RE: Can anyone please help me with implementing session listener.

New Member 投稿: 7 参加年月日: 16/02/17 最新の投稿
Hello Team,

We are also facing the same problem.

We want to limit the number of session which we did successfully.

But it gives an error in the PortletSessionListener saying you are exceeding the max users.

We tried extending the PortletSessionListener by creating a CustomPortletSessionListener.

The problem is -> On running the application i want the CustomPortletSessionListener to block the number of users ranther than this. It still goes to the Liferay's default PortletSessionListener.


Please Suggest


Thanks!
7年前 に Gunnar Brinkmann によって更新されました。

RE: Can anyone please help me with implementing session listener.

Junior Member 投稿: 53 参加年月日: 11/12/02 最新の投稿
Hello.

David H Nebinger:
A portlet session is not the same as a servlet session. You cannot track users by trying to do that. You can use a login/logout action pair, registered with the portal, but logout tracking is very unreliable.

A user can close their browser (not log out).

A user can type in another url or a bookmark or a link that would take them away from the portal, also no logout.

If you're on a cluster, then tracking login/logout is even that much harder.


I'm facing a similar problem at the moment.

We're experiencing what I call "unexpected logouts" (LR 6.2 EE SP14, Portlet, JSF 2.2.12, Primefaces 5.2)

What I've managed to do so far is: I've implemented a hook for "session destroy action" and "logout action", the hook works, I can see my logging on manual logouts and on for example nightly automatic logouts. But I can't see my logging when these "unexpected logouts" happen.

So I planned to add an HttpSessionListener to the portlet, since I still have no clue why these unexpected logouts happen. I feel like they could have something to do with user behaviour or some other client aspects, since these unexpected logouts do not happen very often and only for some users.

I also implemented some Javascript funcionality
- polling server times with ajax
- comparing with client times
- external logging call (some servlet on another server), when an unexpected logout happens (based on server/client time comparisons)

So I can see when these unexpected logouts happen, the timeframe is "10 seconds after last updated server time", and I cound not find any hint in any log so far.

Regards,
Gunnar
thumbnail
7年前 に Neil Griffin によって更新されました。

RE: Can anyone please help me with implementing session listener.

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Gunnar,

I don't know what might be causing your "unexpected logouts" but I wanted to mention that if a user hits a URL with "/c/portal/logout" then the PortletSession will be destroyed.

Neil
7年前 に Gunnar Brinkmann によって更新されました。

RE: Can anyone please help me with implementing session listener.

Junior Member 投稿: 53 参加年月日: 11/12/02 最新の投稿
Thank you Neil, I'll check the resulting HTML code for such urls.

Regards,
Gunnar