1

I am using asp.net and I am using session cookies. When I debug in the browser for the first time then it works fine. When in give a feedback and close the browser. And again I open the browser and again I want to give a feedback then it does not permit me. How can I close the stored cookies and clear the cache?

I am sure that because of the cache and cookies I am facing problem. I have just declare and initialise the cookies like this

    Response.Cookies["MyFeedBack"].Value = "FeedBackYes";

and I am enabling the button in page load by seeing the cookies like this:

     if (Request.Cookies["MyFeedBack"] != null)
        {
            SubmitFeedBackButton.Enabled = false;
        }
        else
        {
            SubmitFeedBackButton.Enabled = true;
        }

When I close the browser then the cookies should be cleared but I find that the cookies are not cleared. When I clear Cache and Cookies by going to the History menu >> Clear Recent History then it works fine. My question is that when I close any of the browser then how can I clear the cache and cookies from the history?

I have tested in three browser namely: Firefox, Google Chrome, and Opera Mini; all the browsers give the same problem.

halfer
  • 19,824
  • 17
  • 99
  • 186
Iswar
  • 2,211
  • 11
  • 40
  • 65

1 Answers1

0

Set the cookie to one day behind

var ckc = new HttpCookie("MyFeedBack") { Expires = DateTime.Now.AddDays(-1) }; HttpContext.Current.Response.Cookies.Add(ckc);