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.
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.
<a href="${URLUtils.sessionRedirect('www.a-brand.com',URLUtils.home())}">Brand A</a>
This example redirects to storefront
homepage for hostname www.a-brand.com
. You can substitute the second parameter with any object of type URL, such as a direct link to a product within another brand.