Session Sharing in Liferay #

The private-session-attributes settings in liferay-portlet.xml determines what session your JSR168 deployed portals will use. This setting affects the sharing of APPLICATION_SCOPE session attributes between the portal, portlets (in the same WAR, and across different WARs) and the servlets in these WARs.

Sharing of session attributes from the portal to private portlets is also determined by the session.shared.attributes setting, which you can override in your portal-ext.properties file. Session attributes with the configured prefix on the portal session will be visible from any private portlets too.

Summary #

  • Non-private portlets read and write to the Portal session.
  • Private portlets write to their own WAR session.
  • Private portlets can read shared attributes of the Portal session. They try to read from their own WAR session first, then looks up any shared attributes copied from the Portal session.
  • Normal servlets only have access to the WAR session, and cannot directly access the Portal session. In order to read shared session attributes, servlets need a private portlet in the same WAR file to copy it for them. Or you can configure your servlet to use the portal session by using Liferay's PortalDelegateServlet mechanism.

For an in depth explaination including diagrams, see my blog posts here:

http://longgoldenears.blogspot.com/2008/03/liferay-session-sharing-demystified.html

http://longgoldenears.blogspot.com/2008/03/portaldelegateservlet-servlet-session.html

0 添付ファイル
56766 参照数
平均 (1 投票)
平均評価は3.0星中の5です。
コメント
コメント 作成者 日時
khó hieeueu quá Nguyen Le 2012/05/18 0:37
is this still valid in liferay 6.1 ?? the denu 2012/10/19 8:44
I am also having the same question. Is this... Sushil Saini 2012/10/22 16:43
Hi Friends,.... Regarding the question. Is this... Sushil Saini 2012/10/24 3:23

投稿日時:12/05/18 0:37
is this still valid in liferay 6.1 ??
投稿日時:12/10/19 8:44
I am also having the same question. Is this still valid in liferay 6.1.1 ?

Because, I have tried the session sharing between portal and servlet using above mentioned way of configuration in liferay version 6.0.6 CE and it worked. ... But now we have upgraded the version of life-ray from 6.0.6 to 6.1.1. And session sharing is not working any more.

Can anyone please help me on this. I am really stuck with it.

Thanks
Sushil Saini
投稿日時:12/10/22 16:43
Hi Friends,.... Regarding the question. Is this still valid in the liferay 6.1.1? ... Answer is yes this is valid in liferay 6.1.1 except a specific scenario ...... which i found, was working in older versions of the liferay but is not working on the liferay 6.1.1.

Scenario: For sharing the session between portlet and servlet declared the portlet as private which is the default settings of the portlet or we can make it by setting private-session-attributes to true in liferay-portlet.xml file. Now the session variables set in APPLICATION_SCOPE by portlet action are accessible by servlet.
But when name of the session variable starts with keyword which defined in property session.shared.attributes in portal-ext.properties file (eg session.shared.attributes= LIFERAY_SHARED, variable name is LIFERAY_SHARED_userid ). In this case the session variable is not accessible in the servlet.
This scenario is working fine with the older versions of liferay but not working with the liferay 6.1.1.

Cheers.
Sushil Kumar Sainiへのコメント。投稿日時:12/10/24 3:23