Search code examples
cookiesliferaysession-cookiesliferay-6portlet

Issue with get liferay login user info


I have deployed one portlet where I can get the user Name, email Id and site ID with following code in my view.jsp,

<%
long id = themeDisplay.getLayout().getGroupId();
long userId = themeDisplay.getUserId();
String fullname= user.getFullName();
System.out.println("USER INFO Testing ==> Full name is: "+fullname+ " Site Id: "+ id + " User Id "+ userId);
%>

In My view.jsp, I am rendering an external web page. In that external web page I am filling one form and on click of submit button I am redirecting the control back to same portlet with another jsp(formData.jsp) by hard coding the URL ("http://localhost:8080/Demo-portlet/formData.jsp").

Now the issue is, I need to get the user info after submit button in the web page.i.e, In view.jsp Is there any way we can set the user info in cookies OR session OR portalUtil OR portletSession and get that info in formData.jsp after submit action?

Or any other easy solution to get user info after submit event?


Solution

  • After login in liferay User information is stored in httpsession object with attribute name : "USER".

    You can get User object by session.getAttribute("USER");