Dear Brothert's
How can i delete or remove a cookie using c#..
Thanks in advance
Best regards
Waqar Hussain Laghari
Dear Brothert's
How can i delete or remove a cookie using c#..
Thanks in advance
Best regards
Waqar Hussain Laghari
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Apr 1, 2009, 1:15 AM EDT
You can delete a cookie using javascript also:
check the following article:
1.http://www.brenz.net/cookies/delete_cookie.asp?absent
2.http://www.dotnetspider.com/resources/15897-Delete-Cookies-using-JavaScript.aspx
3.http://stackoverflow.com/questions/595228/how-can-i-delete-all-cookies-with-javascript
Nipun TomarRank #90 · 23K reputationPosted Mar 31, 2009, 6:11 AM EDT
if you want to delete a particular cookie then
Response.Cookies["cookiename"].Expires = DateTime.Now.AddDays(-1);
if you want to delete all of them
string[] cookies = Request.Cookies.AllKeys;
foreach (string cookie in cookies)
{
Response.Cookies[cookie].Expires = DateTime.Now.AddDays(-1);
}
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Mar 31, 2009, 7:35 AM EDT
You also can try this:
HttpCookieCollection cookieCols = new HttpCookieCollection();
cookieCols = Request.Cookies;
Request.Cookies.Remove("PASS");
Request.Cookies.Remove("UID");
waqar laghari62 reputationPosted Mar 31, 2009, 9:07 PM EDT
Thank you very much for replies.. I tried these both methods. but my cookie is not deleted... If you have any other idea than please please share...
Best regards
Waqar Hussain Laghari
waqar laghari62 reputationPosted Apr 3, 2009, 2:04 AM EDT
Thank you very much... brother Niradhip Chakraborty