Regarding site aliases:Login for Site aliases

Naresh Ede asked on September 14, 2017 14:39

Hii

I have site in kentico with main domain example.com. And i had given different domain aliases for the site like site1.com,site2.com.

If i was logging in example.com, is it possible to log the two alias sites site1.com,site2.com also at the same time.

If possible please provide me the solution to achieve that.

many thanks

Naresh Ede

Recent Answers


Trevor Fayas answered on September 14, 2017 15:52

Hi Naresh,

Session's (that stored the logged in status) are stored in a Cookie on the user's browsers. Because cookies are domain specific, the "logged in" session cookie for example.com is not passed to site1.com nor site2.com

Here's how i worked around it:

First, create a table that has a (Guid) Authorization, (string) UserName, (DateTime) EnterDate.

Next, create a "Site Switcher" Drop down webpart that shows the other websites that the user can switch to. It needs the below logic:

  1. On drop down change, create a new entry for the table with a new random guid, the username, and the current date.
  2. Redirect the user to the other website, passing the authorization guid in the Url (ex: site1.com?auth=abcde-feafead-feafe-aefe)

On the other website, create an "Auto login" webpart, that looks for the authorization guid from the URL. If it finds that Auth in the URL, it needs to do the following:

  1. When it receives the guid, it does a lookup on the table (by authorization GUID) that has an EnterDate within say 2 minutes.
  2. If it finds the record then login the user through Kentico's API, and delete the record.

It may be possible to programatically set the user's session cookie for another domain as well, but i've never tested this and it may not work for security reasons.

0 votesVote for this answer Mark as a Correct answer

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