I am trying to allow the user to set their default language. When a user picks a language from the dropdown and clicks "save", the page is reloaded and the Google Translate cookie is updated- and therefore the site is translated to the language the user picked. On FF and IE, users are able to set the language with the dropdown and then change it to another language. On Chrome, however, the users are able to set the language the first time, but then they cannot change it to a different language.
This issue only shows up on the test and beta site- I can update the language on my localhost.
I am testing with Chrome version 38.
This is the code that sets the Cookie the first time, and also that updates it when a user clicks Save.
public void ImplementUserPreferences(UserPreferences prefs)
{
//examples of prefs.GoogleTranslateDefaultLanguage:
// af, sq, ar, sp, is....
HttpCookie languageCookie = new HttpCookie("googtrans", "/en/" + prefs.GoogleTranslateDefaultLanguage);
AddOrSetCookie(languageCookie, "googtrans");
}
private void AddOrSetCookie(HttpCookie cookie, String cookieName)
{
if (System.Web.HttpContext.Current.Request.Cookies[cookieName] == null)
{
System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
}
else
{
System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
}
}
System.Web.HttpContext.Current.Response.Cookies[cookieName] = cookie
or...Cookies[cookieName].Value = cookie.Value
, or deleting the cookie and re-adding it with a new value? – Pepin