今天刚重装服务器系统,装好了后就不能写入COOKIE了。下面是写入COOKIE的类,大家看看哪出问题了?是代码?还是服务器?public static string ReadCookie(Page ThisP, string CookieSaveName, string Key)
{
string text2;
MethodDefine1.Null();
long num1 = XenoCode.User.Profile.Profile.OnEntry(0x1d);
if (DateTime.Now > DateTime.Parse(string.Intern(d4485e5ae14ac128.cc381ffa3ede662f("\ud2e4\ud9df\ue0dd\ue7e2\ueed3\uf5d3\ufcd1\u03ca\u0aca\u11c8", 0x4fdad2b2))))
{
text2 = "";
}
else
{
string text1 = CookieSaveName;
if (CookieSaveName == "")
{
text1 = ThisP.Request.Url.Host;
}
HttpCookie cookie1 = ThisP.Request.Cookies[text1];
if (cookie1 == null)
{
text2 = "";
}
else
{
try
{
text2 = cookie1[Key].ToString();
}
catch
{
text2 = "";
}
}
}
XenoCode.User.Profile.Profile.OnExit(num1);
return text2;
}
{
string text2;
MethodDefine1.Null();
long num1 = XenoCode.User.Profile.Profile.OnEntry(0x1d);
if (DateTime.Now > DateTime.Parse(string.Intern(d4485e5ae14ac128.cc381ffa3ede662f("\ud2e4\ud9df\ue0dd\ue7e2\ueed3\uf5d3\ufcd1\u03ca\u0aca\u11c8", 0x4fdad2b2))))
{
text2 = "";
}
else
{
string text1 = CookieSaveName;
if (CookieSaveName == "")
{
text1 = ThisP.Request.Url.Host;
}
HttpCookie cookie1 = ThisP.Request.Cookies[text1];
if (cookie1 == null)
{
text2 = "";
}
else
{
try
{
text2 = cookie1[Key].ToString();
}
catch
{
text2 = "";
}
}
}
XenoCode.User.Profile.Profile.OnExit(num1);
return text2;
}
解决方案 »
- 直接给别人下载链接不经过网站的页面怎么知道被下载了多少次?
- 大哥们帮忙看看这个错误是怎么回事啊
- 控制setInterval()的执行次数,但为什么不执行了?
- 一个关于记数的问题~~在线等
- |M| 用Sql触发器更新的时候,如何来判断更新的数据符不符合要求
- 关于Iframe向父页传值同时隐藏自己的问题
- 杭州:找程序高手一起创业
- 初触javascript,帮个忙
- EF 数据迁移遇到的问题
- 请问:如何把这个页面(http://www.htmchina.com/txSite/Script/DownUrl.aspx)DOWN下来?我想看源码,THX
- 有人用过Infragistics的UltraWebGrid吗?打印的问题~
- ASP.NET如何在后台改变客服端控件的值
Cookie.Vaule="xxx";
using System.Collections.Generic;
using System.Text;
using System.Web;/// <summary>
///CookiesHelper 的摘要说明
/// </summary>public class CookiesHelper
{ #region 获取Cookie /// <summary>
/// 获得Cookie的值
/// </summary>
/// <param name="cookieName"></param>
/// <returns></returns>
public static string GetCookieValue(string cookieName)
{
return GetCookieValue(cookieName, null);
} /// <summary>
/// 获得Cookie的值
/// </summary>
/// <param name="cookieName"></param>
/// <param name="key"></param>
/// <returns></returns>
public static string GetCookieValue(string cookieName, string key)
{
HttpRequest request = HttpContext.Current.Request;
if (request != null)
return GetCookieValue(request.Cookies[cookieName], key);
return "";
} /// <summary>
/// 获得Cookie的子键值
/// </summary>
/// <param name="cookie"></param>
/// <param name="key"></param>
/// <returns></returns>
public static string GetCookieValue(HttpCookie cookie, string key)
{
if (cookie != null)
{
if (!string.IsNullOrEmpty(key) && cookie.HasKeys)
return cookie.Values[key];
else
return cookie.Value;
}
return "";
} /// <summary>
/// 获得Cookie
/// </summary>
/// <param name="cookieName"></param>
/// <returns></returns>
public static HttpCookie GetCookie(string cookieName)
{
HttpRequest request = HttpContext.Current.Request;
if (request != null)
return request.Cookies[cookieName];
return null;
} #endregion #region 删除Cookie /// <summary>
/// 删除Cookie
/// </summary>
/// <param name="cookieName"></param>
public static void RemoveCookie(string cookieName)
{
RemoveCookie(cookieName, null);
} /// <summary>
/// 删除Cookie的子键
/// </summary>
/// <param name="cookieName"></param>
/// <param name="key"></param>
public static void RemoveCookie(string cookieName, string key)
{
HttpResponse response = HttpContext.Current.Response;
if (response != null)
{
HttpCookie cookie = response.Cookies[cookieName];
if (cookie != null)
{
if (!string.IsNullOrEmpty(key) && cookie.HasKeys)
cookie.Values.Remove(key);
else
response.Cookies.Remove(cookieName);
}
}
} #endregion #region 设置/修改Cookie /// <summary>
/// 设置Cookie子键的值
/// </summary>
/// <param name="cookieName"></param>
/// <param name="key"></param>
/// <param name="value"></param>
public static void SetCookie(string cookieName, string key, string value)
{
SetCookie(cookieName, key, value, null);
} /// <summary>
/// 设置Cookie值
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static void SetCookie(string key, string value)
{
SetCookie(key, null, value, null);
} /// <summary>
/// 设置Cookie值和过期时间
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="expires"></param>
public static void SetCookie(string key, string value, DateTime expires)
{
SetCookie(key, null, value, expires);
} /// <summary>
/// 设置Cookie过期时间
/// </summary>
/// <param name="cookieName"></param>
/// <param name="expires"></param>
public static void SetCookie(string cookieName, DateTime expires)
{
SetCookie(cookieName, null, null, expires);
} /// <summary>
/// 设置Cookie
/// </summary>
/// <param name="cookieName"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="expires"></param>
public static void SetCookie(string cookieName, string key, string value, DateTime? expires)
{
HttpResponse response = HttpContext.Current.Response;
if (response != null)
{
HttpCookie cookie = response.Cookies[cookieName];
if (cookie != null)
{
if (!string.IsNullOrEmpty(key) && cookie.HasKeys)
cookie.Values.Set(key, value);
else
if (!string.IsNullOrEmpty(value))
cookie.Value = value;
if (expires != null)
cookie.Expires = expires.Value;
response.SetCookie(cookie);
}
} } #endregion #region 添加Cookie /// <summary>
/// 添加Cookie
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static void AddCookie(string key, string value)
{
AddCookie(new HttpCookie(key, value));
} /// <summary>
/// 添加Cookie
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="expires"></param>
public static void AddCookie(string key, string value, DateTime expires)
{
HttpCookie cookie = new HttpCookie(key, value);
cookie.Expires = expires;
AddCookie(cookie);
} /// <summary>
/// 添加为Cookie.Values集合
/// </summary>
/// <param name="cookieName"></param>
/// <param name="key"></param>
/// <param name="value"></param>
public static void AddCookie(string cookieName, string key, string value)
{
HttpCookie cookie = new HttpCookie(cookieName);
cookie.Values.Add(key, value);
AddCookie(cookie);
} /// <summary>
/// 添加为Cookie集合
/// </summary>
/// <param name="cookieName">Cookie名称</param>
/// <param name="expires">过期时间</param>
public static void AddCookie(string cookieName, DateTime expires)
{
HttpCookie cookie = new HttpCookie(cookieName);
cookie.Expires = expires;
AddCookie(cookie);
} /// <summary>
/// 添加为Cookie.Values集合
/// </summary>
/// <param name="cookieName"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="expires"></param>
public static void AddCookie(string cookieName, string key, string value, DateTime expires)
{
HttpCookie cookie = new HttpCookie(cookieName);
cookie.Expires = expires;
cookie.Values.Add(key, value);
AddCookie(cookie);
} /// <summary>
/// 添加Cookie
/// </summary>
/// <param name="cookie"></param>
public static void AddCookie(HttpCookie cookie)
{
HttpResponse response = HttpContext.Current.Response;
if (response != null)
{
//指定客户端脚本是否可以访问[默认为false]
cookie.HttpOnly = true;
//指定统一的Path,比便能通存通取
cookie.Path = "/";
//设置跨域,这样在其它二级域名下就都可以访问到了
//cookie.Domain = "chinesecoo.com";
response.AppendCookie(cookie);
}
} #endregion
//[email protected] 将军
}