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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted Apr 1, 2009, 5:15 AM
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
waqar laghariPosted Apr 3, 2009, 6:04 AM
Thank you very much... brother Niradhip Chakraborty
waqar laghariPosted Apr 1, 2009, 1:07 AM
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
Niradhip ChakrabortyPosted Mar 31, 2009, 11:35 AM
You also can try this:
HttpCookieCollection cookieCols = new HttpCookieCollection();
cookieCols = Request.Cookies;
Request.Cookies.Remove("PASS");
Request.Cookies.Remove("UID");
Nipun TomarPosted Mar 31, 2009, 10:11 AM
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);
}