Session值的存储与删除
private static void SetSession<T>(string key, T val) { HttpContext.Current.Session[key] = (T)val; } private static void RemoveSession(string key) { HttpContext.Current.Session.Remove(key); } private static T GetSession<T>(string key, T def) { var v = HttpContext.Current.Session[key]; if (v != null) { return (T)v; } return default(T); } private static string SmsMobileKey { get { return "_smMobile"; } } public static string SmsMobile { get { return GetSession<string>(SmsMobileKey, ""); } set { if (value == (default(string))) { RemoveSession(SmsMobileKey); } else { SetSession(SmsMobileKey, value); } } }
此随笔或为自己所写、或为转载于网络。仅用于个人收集及备忘。

浙公网安备 33010602011771号