日期:2014-05-18 浏览次数:20416 次
using System;
using System.Web;
namespace Showwin.Common.Web
{
/// <summary>
/// Cookies 的摘要说明。
/// </summary>
public class Cookies
{
public static string Get(string Key)
{
string s = string.Empty;
if(System.Web.HttpContext.Current.Request.Cookies[Key] != null)
{
s = System.Web.HttpContext.Current.Request.Cookies[Key].Value;
}
return s;
}
#region Set
public static void Set(string Key,string Value,bool SaveFlag)
{
HttpCookie cookie = new HttpCookie(Key,Value);
cookie.Path="/";
if(SaveFlag)
{
cookie.Expires = DateTime.Now.AddDays(365);
}
System.Web.HttpContext.Current.Response.AppendCookie(cookie);
}
public static void Set(string Key,string Value)
{
Set(Key,Value,false);
}
#endregion
#region Remove
public static void Remove(string Key)
{
System.Web.HttpContext.Current.Response.Cookies[Key].Expires = DateTime.Now.AddDays(-1);
}
#endregion
}
}
------解决方案--------------------
response.cookies.append(cookie);
这样可以
------解决方案--------------------
HttpCookie cookie = new HttpCookie("cookie2");
cookie.Values.Add("CheckCode", checkCode);
Response.Cookies.Add(cookie);
LZ可以这样试试
------解决方案--------------------
Response.Cookies.Add(myCookie);
改为
Response.AppendCookie(myCookie);
试试~~