Clear Cookie - CSharp System.Web

CSharp examples for System.Web:Cookie

Description

Clear Cookie

Demo Code


using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Web.Security;
using System.Web;
using System.Configuration;
using System.Data;
using System;/*from  w w w  .  j a v  a2s. c  om*/

public class Main{

        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);
        }
}

Related Tutorials