JS cookie Chinese garble code solution
- 2020-03-30 01:33:43
- OfStack
function SetCookie(name, value) {
var exp = new Date();
exp.setTime(exp.getTime() + 3 * 24 * 60 * 60 * 1000); //3 days overdue
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
return true;
};
function getCookie(name) {
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
if (arr != null) return arr[2]; return null;
};
var currentServiceAliasName = getCookie("appName");
var displayName = "";
if (currentServiceAliasName != null && currentServiceAliasName != "" && currentServiceAliasName != "undefined")
displayName = decodeURIComponent(currentServiceAliasName) + " . " + counterName;
else
displayName = counterName;
DecodeURIComponent USES this transformation