/// <summary> /// 读取Cookie某个对象的Value值,返回Value值,如果对象本就不存在,则返回null /// </summary> /// <param name="CookiesName">Cookie对象名称</param> /// <returns>返回对象的Value值,返回Value值,如果对象本就不存在,则返回null</returns> public static string GetCookies(string CookiesName) { if (HttpContext.Current.Request.Cookies[CookiesName] == null) { return(null); } else { return(UEncypt.DESDecrypt(HttpContext.Current.Request.Cookies[CookiesName].Value)); } }
/// <summary> /// 读取Cookie某个对象的Value值,返回Value值,如果对象本就不存在,则返回null /// </summary> /// <param name="CookiesName">Cookie对象名称</param> /// <param name="KeyName">键值</param> /// <returns>返回对象的Value值,返回Value值,如果对象本就不存在,则返回null</returns> public static string GetCookies(string CookiesName, string KeyName) { if (HttpContext.Current.Request.Cookies[CookiesName] == null) { return(null); } else { //如果用下面这个方法,多个key的时候,会报错,20140728 jiangyongsheng //UEncypt.DESDecrypt(HttpContext.Current.Request.Cookies[CookiesName].Value); string strObjValue = HttpContext.Current.Request.Cookies[CookiesName].Value; string strKeyName2 = KeyName + "="; if (strObjValue.IndexOf(strKeyName2) == -1) { return(null); } else { return(UEncypt.DESDecrypt(HttpContext.Current.Request.Cookies[CookiesName][KeyName])); } } }