public static T GetValue(string Key) { Key = "OBJ_" + Key; T t = default(T); if (!Cookies.Exists(Key)) { return(t); } try { string s = Cookies.GetValue(Key, true); byte[] arrBytes = Convert.FromBase64String(s); MemoryStream stream = new MemoryStream(); stream.Write(arrBytes, 0, arrBytes.Length); stream.Seek(0, SeekOrigin.Begin); //BinaryFormatter format = new BinaryFormatter(); XmlSerializer format = new XmlSerializer(typeof(T)); t = (T)format.Deserialize(stream); stream.Close(); } catch { Cookies.Remove(Key); } return(t); }
public static bool Exists(string Key) { Key = "OBJ_" + Key; return(Cookies.Exists(Key)); }