Skip to content

Commit

Permalink
Simplify cookie setting to avoid duplicate language cookies being set
Browse files Browse the repository at this point in the history
  • Loading branch information
donker authored and bdukes committed Oct 31, 2020
1 parent 104a928 commit 2435e14
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions DNN Platform/Library/Services/Localization/Localization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,26 +1569,11 @@ public static void SetLanguage(string value)
}

// save the page culture as a cookie
HttpCookie cookie = response.Cookies.Get("language");
if (cookie == null)
response.Cookies.Remove("language");
if (!string.IsNullOrEmpty(value))
{
if (!string.IsNullOrEmpty(value))
{
cookie = new HttpCookie("language", value) { Path = !string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/" };
response.Cookies.Add(cookie);
}
}
else
{
cookie.Value = value;
if (!string.IsNullOrEmpty(value))
{
response.Cookies.Set(cookie);
}
else
{
response.Cookies.Remove("language");
}
var cookie = new HttpCookie("language", value) { Path = !string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/" };
response.Cookies.Add(cookie);
}
}
catch
Expand Down

0 comments on commit 2435e14

Please sign in to comment.