Most of you probably know that you can get a lot of information about your server environment from the implicit “server” variable scope, however what is not so obvious is why this information is useful. First of all, here is everything you can find out, and their values on my weblog server:
Server variables are most often useful when your code needs to run in multiple environments, and you are not able to develop in a completely platform independent manner. For instance, you might need to to know what the server’s path separator is so that you can reference files on the file system. One way to get this information is from the server.name.os variable, like this:
<cfset pathSep = iif(server.os.name eq "UNIX",de("/"),de("\"))/>
You can also use the server.os.additionalinformation and server.os.version variables to determine if certain ColdFusion functionality (like Verity searches) are supported, or the server.coldfusion.productversion variable to make sure the user has installed your application with the right version of ColdFusion. If you are writing an application that you intend to distribute, and that can potentially be run on any platform that supports ColdFusion, a little platform validation can go a long way toward making installations more user friendly.
What other uses do people have for server variables?