function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aaron Wilson 1Aaron Wilson 1 

How to permit digital experience sites to share logins when using custom domain?

Hello. We have multiple digital experience sites which customers can log in to, each with a custom domain https://x.mycompany.com and hyyps://y.mycompany.com. When users navigate from one to the other they are asked to log in again. How can we modifiy this behaviour so users only have to log in once, and can navigate freely back and forth between the two sites?
SwethaSwetha (Salesforce Developers) 
HI Aaron,
There are 2 use cases here- production &sandbox.

In Production, the domain names would be different for each portal.When the user logs in to "https://portal1.com", Salesforce sets a cookie (sid session cookie) on the root domain "portal1". Later, when "https://portal2.com" is accessed through "https://portal1.com", it sends SAML_Request to "https://portal1.com" -- since there is no sid cookie available for this domain, it asks the user to authenticate to the Community (acting as Identity Provider) so that SAML Response could be generated and POST'ed

In Sandbox, the root domain would remain same so it doesn't ask for authentication because of existing valid cookie on the root domain.
Example:
https://preprod-abc.cs81.force.com/portal1 
https://preprod-abc.cs81.force.com/portal2
This is the reason that SAML Response gets generated and the user gets logged in without having to log in to the 2nd community.

Workaround:
In order to skip the authentication, you need to use seamless navigation between https://portal1.com and
https://portal2.com by using "/servlet/networks/switch?networkId=0DBXXXXxxXXX"

Using the SOQL Query - select id, name from network you can fetch the 15 digits Network Id.

Related links: https://success.salesforce.com/issues_view?id=a1p3A0000017yJdQAI&title=enable-seamless-navigation-across-communities-of-different-custom-domains-without-forcing-users-to-sign-in-twice
 
If this information helps, please mark the answer as best. Thank you