Portlets commonly collect state information that you must save between requests from a client. A way to manage this information is to save it as a session attribute. Portlet sessions are similar to web application sessions, and managing their attributes is the conceptual equivalent.
Portlet sessions do have one major difference. Unlike web application sessions, a Portlet session has scope. A session attribute that is placed in the portlet scope is easily accessible only to the portlet that added it.
portalLib.setPortletSessionAttr("myKey", "myValue", SessionScopeKind.portletScope);