I want to force a website user onto HTTPS when they are entering sensitive information.
Depending on what particular CGI variables are available you could use CFLOCATION.
The code below checks what port the user is on and if it's not
443 (typically https) it redirects the client back to https.
Note: unless you persist your variables any FORM or URL data
sent in the scope will be lost.
<cfif CGI.SERVER_PORT NEQ "443"> <cflocation url="https://#cgi.server_name##cgi.script_name#?#cgi.query_string#" addtoken="no"> </cfif>
Putting the above code on a .cfm page will
always redirect to HTTPS (see comments). However
if you only want selected pages to be on HTTPS you could use
application.cfc on requeststart function to detect the template and
redirect accordantly.
<cfset httpsPage= "cart.cfm,login.cfm"> <cfif cgi.server_port NEQ 443 > <cfif (ListContains( httpsPage,GetFileFromPath(CGI.SCRIPT_NAME),",")) >
<cflocation url="https://#cgi.server_name##cgi.script_name#?#cgi.query_string#" addtoken="no"> </cfif> </cfif>
+