Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 16th, 2006, 08:58 AM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Cookie problem ps0208 Servlets 1 November 5th, 2007 05:55 AM
Cookie Problem jobiweb ASP.NET 1.0 and 1.1 Basics 0 May 12th, 2005 06:10 AM
COOKIE problem Buravik PHP How-To 2 May 9th, 2004 08:47 AM
Session cookie problem rogierio Classic ASP Professional 0 October 15th, 2003 09:50 AM
cookie problem bluewater68 Classic ASP Professional 0 August 26th, 2003 06:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.