.. index:: single: Variable substitution .. _variable_sub: ***************************************************************************** Variable Substitution ***************************************************************************** Syntax: '%' + variable name + '%' .. seealso:: :ref:`runsub`. **Example 1**. Connecting securely to a Spatial Database You want to map some senstitive data held in a PostGIS database. The username and password to be used for the database connection are held in 2 cookies previously set by a seperate authentication mechanism, "uid" and "passwd". .. code-block:: mapfile CONNECTION "user=%uid% password=%passwd% dbname=postgis" **Example 2**. Handling temporary files You have a user based discovery application that generates shapefiles and stores them in a user's home directory on the server. The "username" comes from a cookie, the "filename" comes from a request parameter. .. code-block:: mapfile DATA "/home/%username%/tempshp/%filename%" This feature is only available in the CGI version of MapServer through a mapfile pre-processor. If you are using MapScript, you will have to code the substitution logic into your application yourself (By writing your own pre-processor).