Finding real IP address in coldfusion

Hello,

I was facing one problem before few days as i was storing ip addresses in my database.
when i looked into database i amazed that there were some entries of ip addresses which were not true.

If anyone is connected to internet through Proxy server then using 'CGI.REMOTE_ADDR' just returns the IP address of proxy server not of the user's machine.

What we need to do is to compare 'CGI.HTTP_X_Forwarded_For' variable against 'CGI.REMOTE_ADDR'.

 

<cfif CGI.HTTP_X_Forwarded_For EQ ""><!--- Checking proxy address --->
       <cfset real_ipaddress = CGI.REMOTE_ADDR>
<cfelse>
       <cfset real_ipaddress = CGI.HTTP_X_Forwarded_For>
</cfif>


 

| View count: 314

Comments

Leave a comment

Tell us about yourself
(required field)
(required field)
Comment and preferences


Design by Mark Aplet | Powered by Mango Blog