Testing for CGI variables

Because some browsers do not support some CGI variables, ColdFusion always returns true when it tests for the existence of a CGI variable, regardless of whether the browser supports the variable. To determine if a CGI server exists, test for the availability, as the following example shows:

<cfscript>
myServer=cgi.SERVER_NAME;
if (myServer==cgi.SERVER_NAME)
WriteOutput("Server exists");
else
WriteOutput("Server does not exist");
</cfscript>
<cfscript> myServer=cgi.SERVER_NAME; if (myServer==cgi.SERVER_NAME) WriteOutput("Server exists"); else WriteOutput("Server does not exist"); </cfscript>
<cfscript>
       myServer=cgi.SERVER_NAME;
       if (myServer==cgi.SERVER_NAME)
             WriteOutput("Server exists");
       else
             WriteOutput("Server does not exist");
</cfscript>

To display all CGI variables, use the following code.

<cfscript>
WriteDump(cgi);
</cfscript>
<cfscript> WriteDump(cgi); </cfscript>
<cfscript>
    WriteDump(cgi);
</cfscript>

Get help faster and easier

New user?