private void AppendCookies(string userID, string userName, string name, string forname, string status) { var id = int.Parse(userID); Response.AppendCookie(new HttpCookie("1", CookieEncryption.Encrypt(id).ToString())); Response.AppendCookie(new HttpCookie("2", userName)); Response.AppendCookie(new HttpCookie("3", name)); Response.AppendCookie(new HttpCookie("4", forname)); Response.AppendCookie(new HttpCookie("5", CookieEncryption.Encrypt(status))); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var idCookie = filterContext.HttpContext.Request.Cookies["1"]; var roleCookie = filterContext.HttpContext.Request.Cookies["5"]; if (string.IsNullOrEmpty(idCookie?.Value) || string.IsNullOrEmpty(roleCookie?.Value)) { return; } filterContext.HttpContext.Session["UserID"] = CookieEncryption.Decrypt(int.Parse(filterContext.HttpContext.Request.Cookies["1"].Value)).ToString(); filterContext.HttpContext.Session["UserName"] = filterContext.HttpContext.Request.Cookies["2"].Value; filterContext.HttpContext.Session["Name"] = filterContext.HttpContext.Request.Cookies["3"].Value; filterContext.HttpContext.Session["Forname"] = filterContext.HttpContext.Request.Cookies["4"].Value; filterContext.HttpContext.Session["Status"] = CookieEncryption.Decrypt(filterContext.HttpContext.Request.Cookies["5"].Value); }