I am having trouble getting a cookie to set.
I am processing an order form. From the FORM variables, I pull a query of several items checked off the order form. I want to store the query results (called "pullinfo"
, row by row, in a cookie
(using CFLOOP).
The first time with the first item, my CFIF tests for a cookie, sees no cookie exists, so it sets a new one. Then it adds in the first row of the loop. Fine so far.
On the second (and subsequent passes) CFIF should see a cookie exists, and use a different CFCOOKIE block of code to add the new row to the EXISTING cookie (named "cart"
, viz:
<cfoutput>
<cfcookie name = "cart" value = "#cookie.cart# #quantity#, #pullinfo.itemid#, #pullinfo.item#, #pullinfo.title#, #pullinfo.spec1#, #pullinfo.spec2#, #pullinfo.spec3#, #pullinfo.spec4#;" expires = "1">
</cfoutput>
<!---Note that in adding the new item to the existing cookie, we put no punctuation after cookie.cart because the semicolon we need is already contained inside it. If you add a comma or semicolon here, it will be a DOUBLE and a blank space will be defined as an item.--->
(end of code snippet)
That's my second-pass CFCOOKIE.
Now, the first pass is going through fine, but not the second. What I see is the first pass, along with my watch flag that tells me CFIF saw no cookie. But I also see my debug flag "END OF PASS TWO" which means it DID cycle all the way through. But the second item never got there.
My theory: Could this be a time issue? The only thing I can think of is that the initial cookie just has not finished setting by the time CFLOOP delivers the second row. So CFIF never sees a cookie, and the cookie is overwritten with the first row all over again. Is that possible? Can anybody think of another reason why the second row never gets in? What do YOU do with dumping in multiple rows to a cookie?
I am processing an order form. From the FORM variables, I pull a query of several items checked off the order form. I want to store the query results (called "pullinfo"
(using CFLOOP).
The first time with the first item, my CFIF tests for a cookie, sees no cookie exists, so it sets a new one. Then it adds in the first row of the loop. Fine so far.
On the second (and subsequent passes) CFIF should see a cookie exists, and use a different CFCOOKIE block of code to add the new row to the EXISTING cookie (named "cart"
<cfoutput>
<cfcookie name = "cart" value = "#cookie.cart# #quantity#, #pullinfo.itemid#, #pullinfo.item#, #pullinfo.title#, #pullinfo.spec1#, #pullinfo.spec2#, #pullinfo.spec3#, #pullinfo.spec4#;" expires = "1">
</cfoutput>
<!---Note that in adding the new item to the existing cookie, we put no punctuation after cookie.cart because the semicolon we need is already contained inside it. If you add a comma or semicolon here, it will be a DOUBLE and a blank space will be defined as an item.--->
(end of code snippet)
That's my second-pass CFCOOKIE.
Now, the first pass is going through fine, but not the second. What I see is the first pass, along with my watch flag that tells me CFIF saw no cookie. But I also see my debug flag "END OF PASS TWO" which means it DID cycle all the way through. But the second item never got there.
My theory: Could this be a time issue? The only thing I can think of is that the initial cookie just has not finished setting by the time CFLOOP delivers the second row. So CFIF never sees a cookie, and the cookie is overwritten with the first row all over again. Is that possible? Can anybody think of another reason why the second row never gets in? What do YOU do with dumping in multiple rows to a cookie?