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 run ofbiz as ubuntu Service.

JPA vs Spring JPA vs Spring Data JPA vs Hibernate

Java Array Interview Questions for Entry-Level Developers Part 01