6.19.07 Get Client Request Headers in Coldfusion

Have you needed to acquire the exact values of a specific request header from the client? Do the default CGI variables in Coldfusion not offer access to a specific request header that you need?

If so, the fabled getPageContext() method offers easy access to the string values of these request headers.

<cfoutput>#getPageContext().getRequest().getHeader("Host")#</cfoutput>
<cfoutput>#getPageContext().getRequest().getHeader("Cookie")#</cfoutput>
<cfoutput>#getPageContext().getRequest().getHeader("User-Agent")#</cfoutput>
<cfoutput>#getPageContext().getRequest().getHeader("Referer")#</cfoutput>

No comments




0.206s