1

I am using the below code to remove the a particular cookies.It's worked earlier. But it's not working now. Got error HttpContext.Current is null. I can't guess why it's happen now. Please clarify me.

if (HttpContext.Current.Request.Cookies[name] != null{
  HttpContext.Current.Request.Cookies.Remove(name);
}

Please help me fix this.

user3085540
  • 275
  • 3
  • 12
  • 27

1 Answers1

-1

try this.

 HttpCookieCollection MyCookieCollection = Request.Cookies;
 HttpCookie MyCookie = MyCookieCollection.Get(name);
 if ( MyCookie != null)
 {
     HttpContext.Current.Request.Cookies.Remove(name);
 }
shujaat siddiqui
  • 1,527
  • 1
  • 20
  • 41