CommunityServer - Enabling Language Selection for Anonymous Users

I stumbled upon this great forum discussion today. It details different solutions to allowing anonymous users the option of choosing a website language - without being logged in. The best suggestion is to add new users to the Community Server database (setting "IsAnonymous" to true) one for each country, eg. AnonSpanish, AnonEnglish, etc. Then, adding the following code when the user selects a new language:

if (CSContext.Current.User.IsAnonymous)
{
HttpCookie formsAuthCookie;

if (CSContext.Current.User.Username.Equals("AnonymousSpanish"))
{
formsAuthCookie = FormsAuthentication.GetAuthCookie("Anonymous", false);
}
else
{
formsAuthCookie = FormsAuthentication.GetAuthCookie("AnonymousSpanish", false);
}

UserCookie userCookie = CSContext.Current.User.GetUserCookie();
userCookie.WriteCookie(formsAuthCookie, 365, false); }
↓ Add Comment
↓ Add Comment

Comments (0)