Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookie Issue: Not all cookies being added

Status
Not open for further replies.

jsanborn

Programmer
May 7, 2002
2
US
I have a strange issue happening with cookie creation. I have spent all night last night searching for a solution, including banging my head on the code for a while.

I have a dynamic web form with approximately 20 fields that, after being validated, are written to a cookie. Every time I execute the For...Next loop it appears to work, but not all the fields are added to cookies. I added a test label to see if the loop was executing properly, and it was, so I know the cookie code is executing, but for the life of me, I can't figure out why, every time, it drops the first two or three cookie values. It doesn't matter what the names of these fields care, because even when I change the names, they still don't write to the cookie.

Here is the For...Next code that writes the cookies.

[tt]
'----------------------------------------
Dim FormIndex As Integer
For FormIndex = 0 To Request.Form.Count - 1
Dim Cookie As New HttpCookie("BStore-" & Request.Form.Keys.Item(FormIndex))
Cookie.Name = "BStore-" & Request.Form.Keys.Item(FormIndex)
Cookie.Value = Request.Form.Item(FormIndex)
Cookie.Expires = Now.AddYears(1)
Response.Cookies.Add(Cookie)
Next
'----------------------------------------
[/tt]

Any help would be greatly appreciated!

Jason
 
Have you tried Dim-ing the Cookie and setting its name property out of the loop, add the values inside the loop, then do the Add(Cookie) thing after the loop is done?

Jack
 
Yes, it still removed the first two or three values from the cookie.

Just an additional thought. I know I read somewhere that there can only be 20 cookies assigned to a domain. Could this mean cookie values? I notice that when I cycle through the cookies, that there are only 20 stored in the cookie.

Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top