Changing cookie values

Discussion in 'ASP .Net' started by tshad, Jun 21, 2005.

  1. tshad

    tshad Guest

    I can add a cookie fine, but I can't seem to figure out how to change the
    value of a cookie and save it back.

    My code looks like:

    if (passwordSaveCookie.checked) then
    If Request.Cookies("User") is nothing Then
    Dim cookie As New HttpCookie("User")
    cookie.Values.Add("UserName",UserName.Text)
    cookie.Values.Add("UserFirstName",dbReader("FirstName"))
    cookie.Values.Add("UserLastName",dbReader("LastName"))
    cookie.Expires = DateTime.MaxValue
    Response.AppendCookie(cookie)
    else
    Dim cookie As HTTPCookie = Request.Cookies("User")
    cookie.Values("UserName") = UserName.Text
    cookie.Values("UserFirstName") = dbReader("FirstName")
    cookie.Values("UserLastName") = dbReader("LastName")
    End If
    end if


    I don't get any errors, but when I close my browser and start it back up
    again, the old values are now back.

    If you create the cookie, you use "Response.AppendCookie".

    Is there a corresponding call for updating a current cookie?

    Thanks,

    Tom
     
    tshad, Jun 21, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben
    Replies:
    3
    Views:
    5,861
    Steven Cheng[MSFT]
    Jun 3, 2004
  2. Shapper

    Cookie and Session Cookie Questions.

    Shapper, Apr 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    577
  3. =?Utf-8?B?UGF1bA==?=

    Cookie Question (IP as domain and cookie file location)

    =?Utf-8?B?UGF1bA==?=, Jan 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,487
    Bruce Barker
    Jan 10, 2006
  4. ad
    Replies:
    2
    Views:
    7,527
    Kevin Spencer
    Jan 27, 2006
  5. =?Utf-8?B?TnVubw==?=

    Convert a PHP cookie to an ASP.NET cookie

    =?Utf-8?B?TnVubw==?=, Jan 31, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    444
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jan 31, 2006
Loading...

Share This Page