<!--- Create a response that outputs all of the cookies currently passed in from the AJAX request. In ColdFusion, the cookie collection is populated by the request headers. ---> <cfsavecontent variable="responseText"> <cfoutput> <h3> Cookies ( as of #timeFormat( now(), "hh:mm:ss" )# ) </h3> <ul> <!--- Loop over the cookie collection. ---> <cfloop item="key" collection="#cookie#"> <!--- Only output cookies relevant to this test. ---> <cfif reFindNoCase( "^rand", key )> <li> #key# : #cookie[ key ]# </li> </cfif> </cfloop> </ul> </cfoutput> </cfsavecontent> <!--- Now that we've created the cookie output, let's create a random cookie to set in the current AJAX request. This will get sent back to the client as Set-Cookie header. ---> <cfcookie name="rand#randRange( 111, 999 )#" value="Woot!" /> <!--- Return the HTML response to the client. ---> <cfcontent type="text/html" variable="#toBinary( toBase64( responseText ) )#" />