title: PortletSession using JSF Liferay Portlets
body: <p>I am developing a JSF 2 Portlet, but i need get global session variable.</p>
  
  <p>The request works fine with:</p>
  
  <pre><code>FacesContext facesContext = FacesContext.getCurrentInstance();
      PortletRequest request = (PortletRequest) facesContext.getExternalContext().getRequest();
  </code></pre>
  
  <p>But the session is null:</p>
  
  <pre><code>PortletSession session = request.getPortletSession(false);
  </code></pre>
  
  <p>if put this code in liferay-portlet.xml file works fine, but i can't do IPC: Inter Portlet Comunication</p>
  
  <pre><code>&lt;!-- Portlet session --&gt;
      &lt;private-request-attributes&gt;false&lt;/private-request-attributes&gt;
      &lt;private-session-attributes&gt;false&lt;/private-session-attributes&gt;
  </code></pre>
  
  <p>How i get and set variables session without use the last code?</p>
  
  <p>Thanks </p>
  
  <p>Today i i tried with this:  </p>
  
  <pre><code>FacesContext facesContext = FacesContext.getCurrentInstance(); 
  PortletRequest request = (PortletRequest) facesContext.getExternalContext().getRequest(); 
  HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request); 
  HttpSession session = httpRequest.getSession(true); 
  System.out.println(session.getAttribute("XXXX"));
  </code></pre>
  
  <p>but is null</p>