Maintaining Sessions Across Multiple ColdFusion CFHttp Requests

<!---
	At this point, we have established that multiple requests
	with CFHttp do not inherently keep the session. Now, let's
	figure out what happens when we send across the returned
	cookie values.
--->
 
 
<!---
	Get the cookies from the last response object. These are
	the cookies that we are going to echo back in subsequent
	CFHttp requests.
--->
<cfset objCookies = GetResponseCookies( objGet ) />
 
 
<!---
	Now, let's make a subsequent CFHttp call, but this
	time, we are going to pass in the cookies that were
	returned in the last call to see if we can maintain
	the same session.
--->
<cfhttp
	method="GET"
	url="#strURL#"
	useragent="#strUserAgent#"
	result="objGet">
 
	<!--- Loop over the cookies we found. --->
	<cfloop
		item="strCookie"
		collection="#objCookies#">
 
		<!--- Send the cookie value with this request. --->
		<cfhttpparam
			type="COOKIE"
			name="#strCookie#"
			value="#objCookies[ strCookie ].Value#"
			/>
 
	</cfloop>
 
</cfhttp>
 
 
<!--- Dump out the CFHttp response. --->
<cfdump
	var="#objGet#"
	label="Third CFHttp Request"
	/>

For Cut-and-Paste