Click here to Skip to main content
15,881,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I assign a cookie like below
string sKey = txtUName.Text + txtPwd.Text;
HttpCookie uidpwd = new HttpCookie("uidpwd");
 uidpwd.Value = sKey;
Response.Cookies.Add(uidpwd);


so want to delete it in class file like below

HttpContext.Current.Request.Cookies["uidpwd"].Expires = DateTime.Now.AddSeconds(1);


but throwing an error " Object reference not set to an instance of an object"
Posted

1 solution

I googled "asp.net delete cookie" and this was the first result

https://msdn.microsoft.com/en-us/library/ms178195(v=vs.140).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900