Sharing CurrentContact

Nicholas Gornall asked on September 23, 2020 09:01

Hi, I am trying to track Contacts across two Kentico sites that share a single login page.

My setup is:

  • subdomain 1: WWW
  • subdomain 2: WWW1
  • Authorisation: WWW only, shared for * subdomain

I have observed that

  1. login via the login page on WWW subdomain updates the WWW CurrentContact cookie correctly (anonymous CurrentContact cookie is replaced with user CurrentContact cookie).
  2. The WWW1 CurrentContact cookie does not get update though (anonymous CurrentContact cookie stays anonymous despite being logged in).

Is there a way I can easily share the CurrentContact Cookie across my Kentico sites?

Correct Answer

Dmitry Bastron answered on September 24, 2020 12:43

Hi Nicholas,

I believe you would need to look at customizing CurrentUserContactProvider. Basically, you need to:

  • Implement ICurrentUserContactProvider interface (you can copy Kentico's default implementation to begin with)
  • Amend the logic of GetContactForCurrentUserAndContact method to fetch the correct contact on WWW1 site knowing the user. But check the logic inside Kentico's default first.
  • Register your custom implementation like this: [assembly: RegisterImplementation(typeof(ICurrentUserContactProvider), typeof(CustomCurrentUserContactProvider))]
0 votesVote for this answer Unmark Correct answer

Recent Answers

David te Kloese answered on September 23, 2020 14:41

The cookie will probably not be updated because it's on a different domain.

Contacts and authentication are different things, a contact can be connected to a user. But doesn't need to be the other way around.

How did you configure the "Authorisation: WWW only, shared for * subdomain"

0 votesVote for this answer Mark as a Correct answer

Nicholas Gornall answered on September 24, 2020 00:33

We are using ASP Form authentication with domain="" which allows sharing the auth cookie across subdomains. The WWW site has the only login page and WWW1 redirects users to the WWW login page.

0 votesVote for this answer Mark as a Correct answer

Nicholas Gornall answered on October 13, 2020 05:01

Thanks Dmitry! Looks like implementing ICurrentUserContactProvider achieved the desired outcome.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.