CookieHelper 今天药忘吃喽~ 2023-08-17 17:17 30阅读 0赞 CookieHelper public class CookieHelper { public static CookieHelper Instance { get; } = new CookieHelper(); public void AppendCookie(HttpResponseBase response, tech_admin adminInfo) { HttpCookie cookie = new HttpCookie(Field.AdminCookieId); cookie.Values[Field.AdminType] = DESEncrypt.Encrypt(adminInfo.Admin_type.ToString()); cookie.Values[Field.AdminLoginName] = DESEncrypt.Encrypt(adminInfo.Login_name); //cookie.Values[Field.AdminLoginPwd] = DESEncrypt.Encrypt(adminInfo.Login_pwd); //cookie.Values[Field.AdminCode] = DESEncrypt.Encrypt(adminInfo.Admin_code.ToString()); //cookie.Values[Field.MType] = DESEncrypt.Encrypt(adminInfo.Mtype_id); cookie.Values[Field.MidField] = DESEncrypt.Encrypt(adminInfo.Mid); cookie.Expires = DateTime.Now.AddMinutes(Field.CookieExpireTimeMin); response.AppendCookie(cookie); } public tech_admin GetCookie(HttpRequestBase request) { HttpCookie cookie = request.Cookies.Get(Field.AdminCookieId); if (cookie == null || !cookie.HasKeys) return null; tech_admin adminInfo = new tech_admin(); adminInfo.Login_name = DESEncrypt.Decrypt(cookie.Values[Field.AdminLoginName]); adminInfo.Admin_type = DESEncrypt.Decrypt(cookie.Values[Field.AdminType]).ToInt(); //adminInfo.Login_pwd = DESEncrypt.Decrypt(cookie.Values[Field.AdminLoginPwd]); //adminInfo.Admin_code = DESEncrypt.Decrypt(cookie.Values[Field.AdminCode]).ToInt(); //adminInfo.Mtype_id = DESEncrypt.Decrypt(cookie.Values[Field.MType]); adminInfo.Mid = DESEncrypt.Decrypt(cookie.Values[Field.MidField]); return adminInfo; } public static void RemoveCookie() { HttpCookie model = new HttpCookie(Field.AdminCookieId); model.Expires = DateTime.Now.AddHours(-1); HttpContext.Current.Response.AppendCookie(model); } } 转载于:https://www.cnblogs.com/kikyoqiang/p/11527670.html
相关 CookieHelper CookieHelper public class CookieHelper { public static CookieHe 今天药忘吃喽~/ 2023年08月17日 17:17/ 0 赞/ 30 阅读
相关 CookieHelper帮助类 分享一个操作cookie的帮助类 public class CookieHelper { /// <summary> 你的名字/ 2022年12月23日 00:56/ 0 赞/ 145 阅读
相关 CookieHelper.cs using System; using System.Collections.Generic; using System.Web; using System.Web 系统管理员/ 2022年04月11日 06:26/ 0 赞/ 165 阅读
还没有评论,来说两句吧...