Shared Sessions for a Site with Multiple Domain Aliases

Your company has multiple brands and each brand has its own host name, but they are all part of the same site. You can let customers share baskets and other session information when they switch between brands via a redirect link.

This approach has several advantages, including: To retain session information, the customer clicks a redirect link in the storefront to switch from brand A (host name) to brand B. When clicking a redirect link, the customer stays in the same Salesforce B2C Commerce site and the same session, and the basket is preserved.
Note: This feature only works within one B2C Commerce site: you can't share sessions and baskets across B2C Commerce sites.

Use this API method to provide links between brands on storefront pages:

URL dw.web.URLUtils.sessionRedirect(String host, URL url)

This method generates redirect URLs to the target host names, and preserves the current storefront session. It doesn't work with direct storefront links, only via redirects. If the customer changes the URL, rather than clicking the redirect link, the session isn't preserved.

For example, if a customer goes from brand A to brand B through a direct link (or by typing the URL manually), B2C Commerce creates a new session. Going back to brand A brings the customer to the old session. The cart isn't discarded. However, if the customer goes back to brand A through a redirect link, the customer session from brand B is used and the cart in brand A is discarded.

Code Example

<a href="${URLUtils.sessionRedirect('',URLUtils.home())}">Brand A</a>
This example redirects to storefront homepage for hostname You can substitute the second parameter with any object of type URL, such as a direct link to a product within another brand.
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.