top of page

Jalo Session Overview

​

Jalo session is the wrapper on the top of the HTTP Session. We have HTTP Session in java application similarly Hybris has given the Jalo session. Jalo Session wrapped the data about logged in user detail and settings. 

Every request from a web browser to Hybris is associated with a Jalo Session. During the Jalo Session's instantiation, the SessionContext is preset with system defaults, which depend on the current tenant.  Jalo Session is always associated to the session context and hold the following data: â€‹

  • JaloSession's User

  • JaloSession's Language

  • JaloSession's Currency

  • JaloSession's Pricefactory

  • JaloSession's Locale

  • JaloSession's Timezone

​

​

 

 

​

 

 

 

 

​

Jalo Session Characteristics

​

1) Jalo Session are not persistent they are help only in the memory. The jalo session creation and removal are very fast process since they are not part of persistence layer. A jalo session can not be recovered once it deactivated. 

2) Jalo session are created for each node. 

3) Jalo Session holds a reference to the session cart but the carts are not initiated at the time of creation of Jalo session. The carts  are persistence object and the creation of carts takes  some time. The carts are created on the demand basis by get cart method when they are required. 

4) A JaloSession can be assigned to an HTTP session using the httpSession in a web application. 

​

 

 

​

​

​

 

Jalo Session Life Cycle

​

​

​

​

​

​

​

​

​

​

​

1) Getting a jalo Session : Following are 3 approach to get the jalo session.

  • Jalo Session by  Hybris API: 

JaloSession jaloSession = JaloConnection.createAnonymousCustomerSession();

JaloSession jaloSession = JaloConnection.createSession( Map );

 

  • Using Java Servlet filters, such as HybrisInitFilter.

  • Implicitly by Jsession class. 

final JaloSession session = JaloSession.getCurrentSession();

​

​

2) Instantiating a Jalo Session: When we call the JaloSession.getCurrentSession(), it returns the currently active jalo session and if no instance exist then it will create a new instance by calling the newInstance() method on the JaloSession. 

​

Assigning the tenant ID to the JaloSession, the JaloSession is bound to the currently active tenant. By creating and assigning a SessionID (basically a PK) to the JaloSession, the JaloSession is made identifiable. A set of basic login properties is set to the JaloSession and the user is logged in.

​

​

3) Modifying   a Jalo Session : A jalo session contains the user, currency, language, time and session context related data, sometimes we want to modify these details. For example jalo session created the instance of the anonymous user session  but we have to modify that data for specific user session. 

  • Custom user Setting in Jalo Session:

 jalosession.getSessionContext().setUser( jalosession.getUserManager().getUserByLogin( "customUser" ) );

​

  • Admin User Setting in Jalo Session:

jalosession.getSessionContext().setUser( jalosession.getUserManager().getAdminEmployee() );​

​

  • Language Setting in Jalo Session:

jalosession.getSessionContext().setLanguage( jalosession.getC2LManager().getLanguageByIsoCode( "en_US" ) );

​

​

4) Closing a Jalo Session: Closing a jalo session invalidates the jalo session and if user try to access the application again the new session will be created for this. We can close the Jalo session by following 2 ways.

  • Session timeout by property: 

default.session.timeout = 300​

  • Session timeout by code: 

// 10 second timeout ​

JaloSession.getCurrentSession().setTimeout( 10 );​

//0 second timeout

JaloSession.getCurrentSession().setTimeout( -1 );

JaloSession.getCurrentSession().close();

​

​

​

​

​

​
 

jalo session
jalo session

About the Author

 

Piyush Singh is a seasoned technology enthusiast and educator with a passion for making complex concepts accessible to everyone. With over 10 years of experience in the tech industry working as consultant,  Piyush specializes in Java, Sap Hybris technology and has a knack for breaking down intricate topics into easy-to-follow tutorials.

​​​​​​​

   Connect with Author

LinkedIn

Email

​

​

bottom of page