Sunday, September 14, 2008

Check for an IP Address in coldfusion

<CFIF #left(cgi.remote_addr,7)# is "192.168">
<!--- Your code goes here --->
<cfelseif #left(cgi.remote_addr,7)# is not "192.168">
<CFlocation url = "">

The CFIF tag checks the left "7" digits of the incoming IP which is the cgi.remote_addr variable. If it meets the condition, the code is executed, if not and it meets the cfelseif then the page is redirected to

Pretty simple security to make sure requests only come from certain IPs.

No comments: