The website I work for consists of several projects (written in several languages). Now we need to use some inconvenient code in the query strings and session variables so that the person logs in when they move from project to project. Since cookies are domain-specific, we try to convert them, because they can be installed in one project using one language, but another project (in the same domain) can use it in a different language.
However, I am having problems changing the value of the cookie and deleting it. Or, to be more specific, I am having trouble making any changes to the cookie stick.
For example, in my exit code:
if (Request.Cookies["thisuserlogin"] != null) { HttpCookie myCookie = new HttpCookie("thisuserlogin"); myCookie.Value = String.Empty; myCookie.Expires = DateTime.Now.AddDays(-1d); Response.Cookies.Add(myCookie); Response.Cookies.Set(myCookie); litTest.Text = myCookie.Expires.ToString() + "<br />" + Request.Cookies["thisuserlogin"].Expires.ToString(); }
I finish with one line yesterday and the next line is 1/1/0001 12:00:00, although they MUST be the same cookie. So why, although a cookie was set, this value has not changed? Is there a way to get the user's computer to update the cookie value, including deletion?
Many thanks. PS Any URLs you can provide to give an easy-to-understand tutorial for cookies will be appreciated.
source share