Updating cookies

Results 1 to 2 of 2

Thread: Updating cookies

  1. #1
    Join Date
    Dec 1969

    Default Updating cookies

    Hi, I am trying to update a cookie subkey. The cookie is created on another page when the user logs in and then when the user clicks on a product to purchase this sub below checks if the cartid is empty and if so it creates a random string and is supposed to update the cookie with the string. Sadly when I go and look at the cookie the string is still empty :( <BR><BR>Can anybody help me out here?<BR><BR>Thanks<BR><BR>Private cartid As String<BR><BR>Public Sub addtocart(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)<BR> <BR> If Request.Cookies("userinfo")("cartid") = "" <BR><BR>Then &#039;random string code adapted from Robert Chartier<BR><BR> Dim whatsnext, upper, lower, intcounter As Integer<BR> Randomize() <BR> For intcounter = 1 To 9<BR> whatsnext = Int((1 - 0 + 1) * Rnd() + 0)<BR> If whatsnext = 0 Then<BR><BR> upper = 90<BR> lower = 65<BR> Else<BR> upper = 57<BR> lower = 48<BR><BR><BR> End If<BR> cartid = cartid & Chr(Int((upper - lower + 1) * Rnd() + lower))<BR> Next<BR> Response.Cookies("userinfo")("cartid") = cartid<BR> Else<BR> cartid = (Request.Cookies("userinfo")("cartid"))<BR><BR> End If<BR>

  2. #2
    Join Date
    Dec 1969

    Default Are you aware...

    ...that cookies you set via Response.Cookies are *NOT* available via Request.Cookies on that same page? You have to make the "round trip" to the browser (i.e., get to the next ASP page) before they appear in the Request collection.<BR><BR>If you were aware of that, then did you try "dumping" the Request.Cookies collection, using the code that MS demos in the ASP docs?<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts