Restrict Access Based on IP Address
I'm developing a timeclock application that needs to restrict access based on the visitor's IP Address. This code worked on my testing server but not on any of my production hosts:

<cfset Session.IPAdd="#CGI.Remote_Addr#">
<cfquery name="IPs" datasource="101TC">
SELECT Table_IpAllowed.autonum, Table_IpAllowed.IPAllowed
FROM Table_IpAllowed
WHERE (((Table_IpAllowed.IpAllowed)="<cfoutput>#Session.IPAdd#</cfoutput>"));

<cfif IPs.RecordCount EQ "0">
<cflocation url = "iprejected.cfm">

Based on a couple of forums I visited, this is probably a bug in Access 2007. I finally found some code here that was almost usable. With a few added parentheses the working code became this:

<cfif #cgi.remote_addr# NEQ
"12.345.678.9" AND #cgi.remote_addr# NEQ ""> <!--- Redirect To An Error Invalid Page Access --->
<cflocation url='iprejected.cfm' addtoken='No'> <cfexit method='EXITTEMPLATE'> </cfif>