Question : Coldfusion cfcookie question

Hello experts.
I'm using the jquery rating code(http://orkans-tmp.22web.net/star_rating/).
I'm passing the id of the rated item to a component where i'm storing the rate of one artikel in DB and set  a cookie like:
<CFCOOKIE name="artrate-#arguments.id#" value="#arguments.rate#" expires="never">
so i have for a rating with value 5 for my artikel with id 27 the cookie artrate-27   value 5.

The question is how can i check if i have rated one artikel and get the value?
i can have several cookies looking like
artrate-27
artrate-34 .....
Any help?

Answer : Coldfusion cfcookie question

Right, that's because the example creates just creates new structure each time.  If you want to preserve the values, you need to grab the existing structure from the cookie (if one exists)

<!--- store values in cookie --->
<cfset ratings = {} >
<cfif structKeyExists(COOKIE, "artRate")>
      <cfset ratings = deserializeJSON(COOKIE.artRate)>
</cfif>

Then add any new values to the existing structure, and save it back to the cookie

<cfset ratings[articleID] = rate>
<CFCOOKIE name="artrate" value="#serializeJSON(ratings)#" expires="never">



Random Solutions  
 
programming4us programming4us