Liferay code to check is User login.

There several way to check user isLogin in liferay.

1. In Java code:

From ThemeDisplay object

ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
boolean signedIn = themeDisplay.isSignedIn();


2. In Jsp file:

<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<liferay-theme:defineObjects />

 <c:choose>
  <c:when test="<%= themeDisplay.isSignedIn() %>">
  <c:when>

 <c:otherwise>
 <c:otherwise>
</c:choose>

3. In vm file :

if ($is_signed_in)

 4. In Web content template:

#set ($isSignedIn = $request.get("remote-user"))

#if ($isSignedIn!='')

#end

 5. In javascript file:

 <script >
  $(document).ready(function(){
         if((Liferay.ThemeDisplay.isSignedIn())){
       
        }
  }); 

</script> 

Comments

Popular posts from this blog

How to find the companyId in Liferay.

How to add portlet in liferay theme.

How to create soap client for ofbiz service or ofbiz service invocation from another application.