LISTING 1: sso.cfm

<!--- make http request to login.cfm--->
<cfhttp method="get" url="http://testsso.com/login.cfm">
</cfhttp>

<!-- pick out cookie information and store in temporary structure--->
<cfset tempCookieStruct ="#cfhttp.responseheader['Set-Cookie']#">

<!--- loop through cookie structure and reformat into new structure with cookie
name as key and cookie value as key value--->
<cfset cookieStruct=StructNew()>
<cfloop collection="#tempCookieStruct#" item="key">
	<cfset cookieKeyAndValue=ListGetAt(tempcookieStruct[key],1,';')>
	<cfset cookieKey=ListGetAt(cookieKeyAndValue,1,'=')>
	<cfset cookieValue=ListGetAt(cookieKeyAndValue,2,'=')>
	<cfset StructInsert(cookieStruct,cookieKey,cookieValue)>
</cfloop>

<!--- send the user credentials with previous cookies via HTTP post--->
<cfhttp method="post" url="http://testsso.com/processlogin.cfm;jsessionid=#cookieStruct.JSESSIONID#">
	<cfloop collection="#cookieStruct#" item="key">
		<cfhttpparam type="cookie" name="#key#" value="#cookieStruct[key]#">
	</cfloop>
	<cfhttpparam type="formfield" name="username" value="user1">
	<cfhttpparam type="formfield" name="password" value="mypwd">
</cfhttp>

<!--- redirect user to main page of new application--->
 <cfhttp method="get" url="http://testsso.com/index.cfm;jsessionid=#cookieStruct.jsessionid#">
	<cfloop collection="#cookieStruct#" item="key">
		<cfhttpparam type="cookie" name="#key#" value="#cookieStruct[key]#">
	</cfloop>
</cfhttp>

<cfoutput>
<script language="javascript">
<cfloop collection="#cookieStruct#" item="key">
	document.cookie='#key#=#cookieStruct.jsessionid#;path=/';
</cfloop>

window.open('http://testsso.com/index.cfm;jsessionid=#cookieStruct.jsessionid#',
'SelectWindow','width=800,height=300,resizable=yes,status=yes,menubar=yes,toolbar=yes,
scrollbars=yes');
</script>
</cfoutput>

Listing 2: setCookies.html

<SCRIPT language="JavaScript1.1">
var queryString = document.location.search;

 // take out ? to get query string
queryString = queryString.substring( 1 );

// parse parameters based on &
var cookies= queryString.split( '&' );
for ( i=0; i<cookies.length; i++ ){
document.cookie=unescape(cookies[i]);
}

document.location.replace('http://150.216.184.31/lochz/portal/index.cfm');
</SCRIPT>

Listing 3: modified sso.cfm

<cfset cookieString="">
<cfloop collection="#cookieStruct#" item="key">
	<cfset cookieString=cookieString & "#key#%3d#cookieStruct[key]#;path%3d/&">
</cfloop>

<cfoutput>
<script language="javascript">
window.open('testsso.com/setCookies.html?#cookieString#','SelectWindow',
'width=800,height=300');
</script>
</cfoutput>