/// <summary> /// Pokud chci zapsat null, nestačí poslat pouze null, musí to být string null /// </summary> /// <param name="args"></param> public void WritePernamentCookie(string nameOfCookie, params string[] args) { // create a cookie HttpCookie cookie = null; if (!this.Request.IsLocal) { cookie = new HttpCookie(nameOfCookie); } else { cookie = new HttpCookie("localhost." + nameOfCookie); } //Add key-values in the cookie for (int i = 0; i < args.Length; i++) { string key = args[i]; string value = args[++i]; if (value == null) { value = ""; } if (key == "sc") { value = ConvertRot12.To(value); } cookie.Values.Add(key, value); } cookie.Expires = DateTime.Now.AddYears(1); Response.Cookies.Add(cookie); }
public static string ReadPermanentCookieSingleValue(HttpRequest req, string nameOfCookie) { HttpCookie myCookie = GetExistsOrNew(req, nameOfCookie); if (nameOfCookie == CookieNames.sCzSc) { return(ConvertRot12.From(myCookie.Value)); } return(myCookie.Value); }
public void WritePernamentCookieSingleValue(string nameOfCookie, string value) { HttpCookie cookie = new HttpCookie(nameOfCookie); if (nameOfCookie == CookieNames.sCzSc) { value = ConvertRot12.To(value); } cookie.Value = value; cookie.Expires = DateTime.Now.AddYears(1); Response.Cookies.Add(cookie); }
public string[] ReadPermanentCookie(string nameOfCookie, params string[] keys) { HttpCookie cookie = null; cookie = GetExistsOrNew(Page.Request, nameOfCookie); if (cookie == null) { return(new string[0]); } string[] result = new string[keys.Length]; // ok - cookie is found. for (int i = 0; i < keys.Length; i++) { string o = cookie.Values[keys[i]]; if (!string.IsNullOrEmpty(o)) { if (o == null) { result[i] = null; } else { if (keys[i] == "sc") { result[i] = ConvertRot12.From(o); } else { result[i] = o; } } } else { result[i] = null; } } return(result); }