Enabling global persistent sessions
HCL Commerce can be configured to enable persistent sessions for both
registered and guest users. Enabling persistent sessions allows for some session-related information
of the user to be stored as permanent cookies. If persistent sessions are enabled, a customer at a
HCL Commerce store will be recognized on subsequent visits to the store, even after the
customer closes the browser.
Procedure
Enable persistent sessions globally (handles only registered customers by
default).
- Open the configuration file.
-
Locate
PersistentSessionelement within theSessionManagementcode:<SessionManagement> <url-rewriting display="false" enabled="false"/> <cookie acceptance="false" age="-1" display="false" domain="" enabled="true" path="/" persistence="wcs"/> <referrerCookie age="-1"/> <AllowMultipleLogonForSameUser enabled="true"/> <PersistentSessioncookieExpiry="-1"delayNewPersistentGuestSession="true" display="false"enable="false"/> <PersonalizationId display="false" enable="true"/> </SessionManagement> -
In the
cookieExpiryattribute, enter the number of days that you want the session to last. If the customer logs on to the store within the specified number of days, their session is persisted. A value of -1 indicates that the cookie is removed at the end of a browser session, and a value of 0 is not supported. Set the enable attribute to true. - Optional:
Enable the Migrate Guest Orders Event Listener for guest customers in persistent
sessions.
This event listener is defined within the
GuestUserOrderResetEventListenerclass and is used to listen for guest user migration events. When an event occurs, the listener class resets the pending orders that belong to the previous guest user, clearing all of the private information that belongs to the order. The class then sets the ownership of the order to the new guest user.For example, when persistent sessions are enabled and a guest shopper adds an item to their shopping cart, guest user A is created. If the shopper closes and then opens their web browser again, they can still view the item within the shopping cart. When the shopper adds another item to their cart, or performs an action that is not allowed with persistent sessions, a new guest user B is created. The actions that are allowed by persistent sessions are configured in the corresponding struts configuration file. With guest user B created, the enablement of the event listener determines the shopping cart contents. If enabled, the guest user A shopping cart is migrated to guest user B and the contents of the cart are merged. This migration provides the shopper with a consistent shopping experience without the shopper knowing that a second guest user session is created.Note: This event listener class is used only for persistent sessions. If persistent sessions are not enabled, the listener is not used, regardless of whether you enable the listener. - Save and close the file.
- Restart the Transaction server and the Store server.
-
Ensure that your store is configured to manage persistent sessions. For
example, your
STORE.PERSISTENTSESSIONvalue must correspond to the configuration you want to support, such as remembering registered customers only, or remembering both registered and guest customers. If you want registered customers to use persistent session features, create a check box on the logon and registration page that enables the feature for their account.Note: For a JSP-based store, you might need to update store JSP pages to ensure your persistent session option displays correctly.