T
th3dude
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("myCookie");
}
cookie["Name"] = "myName";
cookie["PW"] = "myPw";
cookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie);
lbl_welcome.Text = "<b>Cookie Created.</b>";
lbl_welcome.Text = "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.AddMinutes(-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("myCookie");
}
cookie["Name"] = "myName";
cookie["PW"] = "myPw";
cookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie);
lbl_welcome.Text = "<b>Cookie Created.</b>";
lbl_welcome.Text = "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.AddMinutes(-1);
}
}
What am i missing here, seems fairly simple?
Thanks for any help!