Hi,
I have a load of order data that i want to store in a session until the order has been submitted. Once this order has been submitted the data will be written to the database.
What I have at the moment is a load of session variables defining this that and the other. What i was thinking of doing os to create a session variable that is a structure and then add this order data into that.
this is what i have at the moment:
<CFLOOP QUERY="getOrder">
<CFLOCK TIMEOUT="10" THROWONTIMEOUT="No" NAME="#Session.SessionID#" TYPE="Exclusive">
<CFIF isDefined('Session.Cart') IS "No">
<CFSET Session.Cart = StructNew()> </CFIF>
<CFSCRIPT>
StructInsert(Session.Cart,"ProductCode","getOrder.ProductCode"
;
</CFSCRIPT>
</CFLOOP>
When i run this code i get:
Cannot insert item with key ProductCode...possibly key already exists
I have got 8 records that are returned by the database that i want to put into this structure. Do i have to have a new structure for each order row that is returned ?
I have used the CFSET method and did not get this error message but then that only inserted one row of data into the structure.
I have seen a structure used before in this way but can't currently find the code that was used to do this.
does anyone have any ideas on how i can have multiple enteries in one structure
I have a load of order data that i want to store in a session until the order has been submitted. Once this order has been submitted the data will be written to the database.
What I have at the moment is a load of session variables defining this that and the other. What i was thinking of doing os to create a session variable that is a structure and then add this order data into that.
this is what i have at the moment:
<CFLOOP QUERY="getOrder">
<CFLOCK TIMEOUT="10" THROWONTIMEOUT="No" NAME="#Session.SessionID#" TYPE="Exclusive">
<CFIF isDefined('Session.Cart') IS "No">
<CFSET Session.Cart = StructNew()> </CFIF>
<CFSCRIPT>
StructInsert(Session.Cart,"ProductCode","getOrder.ProductCode"

</CFSCRIPT>
</CFLOOP>
When i run this code i get:
Cannot insert item with key ProductCode...possibly key already exists
I have got 8 records that are returned by the database that i want to put into this structure. Do i have to have a new structure for each order row that is returned ?
I have used the CFSET method and did not get this error message but then that only inserted one row of data into the structure.
I have seen a structure used before in this way but can't currently find the code that was used to do this.
does anyone have any ideas on how i can have multiple enteries in one structure