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); } } }