Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Outject session scoped attributes from portlet to portal
Hello Community,
we've got a very simple requierement to show some information about the logged in user in a header of a portal. For that simple feature i would "outject" some attribute into the global session scope of the logged in user and grasp it somewhere in an .ftl template e.g.:
HttpSession session = request.getSession(); session.setAttribute("MYATTR", attrvalue);
just in the near of the
session.setAttribute(CASWebKeys.CAS_LOGIN, login);
But this intuitive approach just won't work for MYATTR (despite it nicely works for CAS_LOGIN). I already tried to prefix the attribute with LIFERAY_SHARED_ but without effect. It worth mentioning that the documentation of
session.shared.attributes
already warns about the impossibility:
Note that this property is used to specify the sharing of session attributes from the portal to the portlet. This is not used to specify session sharing between portlet WARs or from the portlet to the portal.
but what is the correct solution for such a simple requirement?
Thank you and regards, Gena
If you're in a portlet, try setting private-session-attributes to false.
However you may want to read Dave's blog on this issue and find a different method to achieve what you want:
https://community.liferay.com/blogs/-/blogs/resident-evil-death-to-sessions
Powered by Liferay™