Reset contact cookie on log out

Dmitriy Nenazhenko asked on March 5, 2018 10:36

Hi,

I faced a problem when logging in the website with membership. It connects User with Contact. But when we sign out it doesn't reset the contact. So if we log in with different credentials at won't create new contact but assign two users to one contact. How can we avoid this and set one to one user-contact relation?

Recent Answers


David te Kloese answered on March 5, 2018 10:55

See the documentation on devnet for more detailed information how the contacts work.

It basically says there isn't a direct relation between a user and contact. The relationship is created using a 'membership mapping table'. This defines the usersID to link it to a contact.

By default when a visitor: * Registers an account * Logs in * enters customer data in a checkout process * or Subscribes to a newsletter

A link between a user and contact is created.

You could create custom code to override the recognition method Kentico uses, using the following sample in the documentation:

docs.kentico.com/.../configuring-contact-recognition

0 votesVote for this answer Mark as a Correct answer

Dmitriy Nenazhenko answered on March 5, 2018 11:43

Can you may be suggest a way how we can reset current contact when user logs out? So if user logged out new contact would be created.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on March 5, 2018 13:25

Well I think you still need to alter the recognition I mentioned before:

docs.kentico.com/.../configuring-contact-recognition

In the SetCurrentContact() you create your own logic.

You could create a custom event handler that calls this method in on logout.

You might also need to create an event when signed in again since you want to select/set the contact corresponding to your user again.

0 votesVote for this answer Mark as a Correct answer

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