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
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