This seems like an easy one, but i'm stuck on getting rid of a cookie
and cannot seem to make it happen.
I'm creating a cookie like so:
private void createCookie()
{
HttpCookie cookie = Request.Cookies["myCookie"];
if (cookie == null)
{
cookie = new HttpCookie("myC ookie");
}
cookie["Name"] = "myName";
cookie["PW"] = "myPw";
cookie.Expires = DateTime.Now.Ad dDays(1);
Response.Cookie s.Add(cookie);
lbl_welcome.Tex t = "<b>Cookie Created.</b>";
lbl_welcome.Tex t = "Logged in As: " + cookie["Name"] + "
Pw: " + cookie["PW"];
}
Then upon clicking a button i'm trying to get rid of the cookie (but
it does not go away):
private void doLogout()
{
HttpCookie cookie = Request.Cookies["myCookie"];
if (cookie != null)
{
cookie.Expires = DateTime.Now.Ad dMinutes(-1);
}
}
What am i missing here, seems fairly simple?
Thanks for any help!
and cannot seem to make it happen.
I'm creating a cookie like so:
private void createCookie()
{
HttpCookie cookie = Request.Cookies["myCookie"];
if (cookie == null)
{
cookie = new HttpCookie("myC ookie");
}
cookie["Name"] = "myName";
cookie["PW"] = "myPw";
cookie.Expires = DateTime.Now.Ad dDays(1);
Response.Cookie s.Add(cookie);
lbl_welcome.Tex t = "<b>Cookie Created.</b>";
lbl_welcome.Tex t = "Logged in As: " + cookie["Name"] + "
Pw: " + cookie["PW"];
}
Then upon clicking a button i'm trying to get rid of the cookie (but
it does not go away):
private void doLogout()
{
HttpCookie cookie = Request.Cookies["myCookie"];
if (cookie != null)
{
cookie.Expires = DateTime.Now.Ad dMinutes(-1);
}
}
What am i missing here, seems fairly simple?
Thanks for any help!
Comment