Try deleting it this way:
if (Request.Cookies["g"] != null)
{
HttpCookie myCookie = new HttpCookie("g");
myCookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(myCookie);
}
I think if you try creating the cookie and adding it to the Response like this it should work.
You want to add in a new cookie to the response that has the same name. Also I recommend going back a day and not just an hour.
To change the value of the cookie do this:
if (Request.Cookies["g"] != null)
{
HttpCookie myCookie = new HttpCookie("g");
myCookie.Expires = DateTime.Now.AddHours(1);
myCookie.Value = "n";
Response.Cookies.Add(myCookie);
}
The important thing to note with these examples is that we are observing the read-only request collection to see what is already in there, and then we are making changes or deleting by adding a new cookie to replace the one that was there before.