VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > Python基础教程 >
  • C#教程之c#cookie读取写入操作


public static void SetCookie(string cname, string value, int effective)
        {
            HttpCookie cookie = new HttpCookie(cname);
            cookie.Value = value;
            cookie.Expires = DateTime.Now.AddDays(effective);
            HttpContext.Current.Response.Cookies.Add(cookie);
        }

        public static object GetCookie(string cname)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[cname];
            return cookie;
        }

        public static void RemoveCookie(string name)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[name];
            if (cookie != null)
            {
                cookie.Expires = DateTime.Now.AddDays(-10);
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
        } 
复制代码


相关教程