国产一区黄,国产夫妻一区,免费在线观看黄色小视频,日本黄色免费在线,久亚洲精品不子伦一区,日99久9在线免费,亚洲欧美日韩国产精品b站在线看

主營(yíng)業(yè)務(wù):網(wǎng)站制作 網(wǎng)站優(yōu)化 小程序制作 石家莊網(wǎng)站制作網(wǎng)站建設(shè)有限公司歡迎您!
石家莊閃云網(wǎng)絡(luò)科技有限公司
客服熱線15383239821
如何讓自己的網(wǎng)站更有質(zhì)量?

cook 的設(shè)置

發(fā)布時(shí)間:2010/10/23 18:38:50
/// <summary>
///cook 的設(shè)置
/// </summary>
public class CooksTO
{
/// <summary>
/// 保存一個(gè)Cookie
/// </summary>
/// <param name="CookieName">Cookie名稱</param>
/// <param name="CookieValue">Cookie值</param>
/// <param name="CookieTime">Cookie過(guò)期時(shí)間(小時(shí)),0為關(guān)閉頁(yè)面失效</param>
public static void SaveCookie(string CookieName, string CookieValue, double CookieTime)
{
HttpCookie myCookie = new HttpCookie(CookieName);
DateTime now = DateTime.Now;
myCookie.Value = CookieValue;
if (CookieTime != 0)
{
myCookie.Expires = now.AddDays(CookieTime);
if (HttpContext.Current.Response.Cookies[CookieName] != null)
HttpContext.Current.Response.Cookies.Remove(CookieName);
HttpContext.Current.Response.Cookies.Add(myCookie);
}
else
{
if (HttpContext.Current.Response.Cookies[CookieName] != null)
HttpContext.Current.Response.Cookies.Remove(CookieName);
HttpContext.Current.Response.Cookies.Add(myCookie);
}
}

/// <summary>
/// 取得CookieValue
/// </summary>
/// <param name="CookieName">Cookie名稱</param>
/// <returns>Cookie的值</returns>
public static string GetCookie(string CookieName)
{
HttpCookie myCookie = new HttpCookie(CookieName);
myCookie = HttpContext.Current.Request.Cookies[CookieName];
if (myCookie != null)
return myCookie.Value;
else
return null;
}

/// <summary>
/// 清除CookieValue
/// </summary>
/// <param name="CookieName">Cookie名稱</param>
public static void ClearCookie(string CookieName)
{
HttpCookie myCookie = new HttpCookie(CookieName);
DateTime now = DateTime.Now;
myCookie.Expires = now.AddYears(-2);
HttpContext.Current.Response.Cookies.Add(myCookie);
}
}


 

相關(guān)新聞推薦

在線客服 : 服務(wù)熱線:15383239821 電子郵箱: 27535611@qq.com

公司地址:石家莊市新華區(qū)九中街江西大廈4062

備案號(hào):冀ICP備2022000585號(hào)-4