Cookie problem
I have made a registration form and all values must be stored into a cookie.
[u]Page load:</u>
protected void Page_Load(object sender, EventArgs e) {
if (Request.Cookies["jaCookie"] != null) {
this.naamTxt.Text = Request.Cookies["jaCookie"]["naam"];
this.straatTxt.Text = Request.Cookies["jaCookie"]["adres"];
this.gemeenteTxt.Text = Request.Cookies["jaCookie"]["gemeente"];
this.postcodeTxt.Text = Request.Cookies["jaCookie"]["postcode"];
this.telNrTxt.Text = Request.Cookies["jaCookie"]["telNr"];
this.emailTxt.Text = Request.Cookies["jaCookie"]["email"];
}
}
[u]Code for making/rewriting the cookie:</u>
protected void CreateCookie() {
DateTime ExpiryDate = DateTime.Now.AddDays(1);
HttpCookie testCookie = new HttpCookie("jaCookie");
testCookie.Values["naam"].Replace(testCookie["naam"], this.naamTxt.Text);// testCookie.Values["naam"] = this.naamTxt.Text;
testCookie.Values["adres"] = this.straatTxt.Text;
testCookie.Values["gemeente"] = this.gemeenteTxt.Text;
testCookie.Values["postcode"] = this.postcodeTxt.Text;
testCookie.Values["telNr"] = this.telNrTxt.Text;
testCookie.Values["email"] = this.emailTxt.Text;
testCookie.Expires = ExpiryDate;
Response.Cookies.Add(testCookie);
}
The problem is that when I want to change one of the Values after pushing the submit button (and the method here above is being executed), this never works. Somhowe, the new values from the Textboxes don't get stored into the cookie and the values that were given in by the user for the first time he/she visits the site remain.
Where is my fault and how to rewrite the values?
|