复制代码 代码如下:
Response.Cookies("MyCookie").Domain = "vevb.com";
Response.Cookies("MyCookie").Path = "http://www.vevb.com/"
Response.Cookies("MyCookie").Expires = Now + 365;
Response.Cookies("MyCookie")("Test") = "test";
复制代码 代码如下:
HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies[cookiename];
if (cookie != null)
{
cookie.Values.Clear();
SetUserCookieExpireTime(cookiename, -1);
cookie.Domain = _domain;
System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
}
public static void SetUserCookieExpireTime(string key, int days)
{
System.Web.HttpContext.Current.Response.Cookies[key].Domain = _domain;
System.Web.HttpContext.Current.Response.Cookies[key].Path = _cookiepath;
System.Web.HttpContext.Current.Response.Cookies[key].Expires = DateTime.Now.AddDays(days);
}
复制代码 代码如下:
public static void AddUserCookies(string key,string value, string cookiename, string domain)
{
HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies[cookiename];
if (cookie == null)
{
cookie = new HttpCookie(cookiename);
cookie.Domain = domain;
cookie.Path = _cookiepath;
cookie.Values.Add(key, value);
HttpContext.Current.Response.AppendCookie(cookie);
}
else
{
if (System.Web.HttpContext.Current.Request.Cookies[cookiename].Values[key] != null)
{
cookie.Values.Set(key, value);
}
else
{
cookie.Domain = domain;
cookie.Path = _cookiepath;
cookie.Values.Add(key, value);
HttpContext.Current.Response.AppendCookie(cookie);
}
}
}
复制代码 代码如下:
Response.Cookies("domain").Value = DateTime.Now.ToString
Response.Cookies("domain").Expires = DateTime.Now.AddDays(1)
Response.Cookies("domain").Domain = "s.vevb.com"
复制代码 代码如下:
Response.Cookies("domain").Value = DateTime.Now.ToString
Response.Cookies("domain").Expires = DateTime.Now.AddDays(1)
Response.Cookies("domain").Domain = "vevb.com"
新闻热点
疑难解答
图片精选