Skip to main content
Known Participant
November 11, 2010
Question

how get the IP of visitor in CFML

  • November 11, 2010
  • 2 replies
  • 899 views

I want get the IP of visitor in CFML?

    This topic has been closed for replies.

    2 replies

    Known Participant
    November 11, 2010

    <?php function getIP()
    {
          if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
          else if (isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
          else $ip = “UNKNOWN”;
          return $ip;
    }

    $ref=$_SERVER['HTTP_REFERER'];

    $userAgent=$_SERVER['HTTP_USER_AGENT']; ?>

    also this PHP code how translated in cfml?

    Inspiring
    November 11, 2010

    Try this,



    <CFIF
    #CGI.HTTP_X_Forwarded_For# EQ "">
         <CFSET ipaddress="#CGI.Remote_Addr#">
    <CFELSE>
         <CFSET ipaddress="#CGI.HTTP_X_Forwarded_For#">
    </CFIF>

    <CFSET ref = "#CGI.HTTP REFERER#">
    <CFSET userAgent = "#CGI.HTTP_USER_AGENT#">

    HTH

    Inspiring
    November 11, 2010

    Hi,

    Use #CGI.REMOTE_ADDR#

    HTH