RE: httpsession attribute sharing between modules Liferay 7.1

Abdul Kareem, modified 6 Years ago. Junior Member Posts: 30 Join Date: 9/4/14 Recent Posts
I wanted to share some value between PostloginAction and module. But I am getting null in module.

In PostLoginAction:
 httpSession.setAttribute("LIFERAY_SHARED_USER_ORG", organization);

In other module:
 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(portletRequest);
           HttpSession httpSession = httpReq.getSession();
           Object sessionObj = httpSession.
                     getAttribute("LIFERAY_SHARED_USER_ORG");
           if(sessionObj != null){
                userOrg = (Organization)sessionObj;
           }

Alway i am getting null value.

Thanks,
​​​​​​​Abdul
thumbnail
Olaf Kock, modified 6 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Abdul KareemI wanted to share some value between PostloginAction and module. But I am getting null in module.
I've recently answered a similar question on stackoverflow, with a link back to the blogs on this site. It may provide some insight and hints.
And this related recent question on stackoverflow might provide some additional background on the sharing between a non-portlet and portlet-module.
Abdul Kareem, modified 6 Years ago. Junior Member Posts: 30 Join Date: 9/4/14 Recent Posts
Thanks Olaf for the response.

I got the solution for this.

HttpServletRequest httpActualServletRequest = PortalUtil.getHttpServletRequest(renderRequest);HttpSession httpSession = PortalUtil.getOriginalServletRequest(httpActualServletRequest).getSession();

Using the above code I am getting the value.

Thanks,
​​​​​​​Abdul Kareem