public class CustomizeSession { private HttpSessionState _sesssion = HttpContext.Current.Session; public void SetSession(string key,string value) { _sesssion[key] = value; //string id = _sesssion.SessionID; } public int GetSessionNumber(string key) { int result = 0; if (_sesssion[key]!=null) { int.TryParse(_sesssion[key].ToString(),out result); } return result; } public string GetSessionString(string key) { string result = ""; if (_sesssion[key]!=null) { result = _sesssion[key].ToString(); } return result; } public void SetTimeOut(int timeout) { _sesssion.Timeout = timeout;//min } public void Clear() { _sesssion.Clear(); } }
时间: 2024-12-18 22:14:04