home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / cfapplication1.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  2.8 KB  |  67 lines

  1. <!--- This is a view-only example to illustrate CFAPPLICATION --->
  2. <!------------------------------------------------------------- 
  3.     This example shows how CFLOCK can be used to guarantee the
  4.     consistency of data updates to variables in the Application, 
  5.     Server, and Session scopes if session management is
  6.     turned on with the CFAPPLICATION tag in Application.cfm.
  7.     You should copy the following code into an Application.cfm
  8.     file in the wwwroot directory. Take out the comments
  9.     around the code to enable it.
  10. --------------------------------------------------------------->
  11.     <HTML>
  12.     <HEAD>
  13.         <title>Define Session and Application Variables</title>
  14.     </HEAD>
  15.     
  16.     <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  17.     <BODY  bgcolor="#FFFFD5">
  18.     
  19.     <H3>CFAPPLICATION Example</H3>
  20.     
  21.     <P>CFAPPLICATION defines scoping for a ColdFusion application and 
  22.     enables or disables the storing of application and/or session
  23.     variables. This tag is placed in a special file called
  24.     Application.cfm that is run before any other CF template in a
  25.     directory where the Application.cfm file appears.
  26.     <!------------------------------------------------------------- 
  27.      <CFAPPLICATION NAME="ETurtle" SESSIONTIMEOUT=#CreateTimeSpan(0, 0, 
  28.       0, 60)# SESSIONMANAGEMENT="yes">
  29.     --------------------------------------------------------------->   
  30.     <!------------------------------------------------------------- 
  31.     Initialize the session and application variables that will be 
  32.     used by E-Turtleneck. Use the session scope for the session 
  33.     variables.
  34.     ---------------------------------------------------------------> 
  35.     <!------------------------------------------------------------- 
  36.     <CFLOCK SCOPE="Session" TIMEOUT="30" TYPE="Exclusive">
  37.         <CFIF NOT IsDefined("session.size")>
  38.             <CFSET session.size = "">
  39.         </CFIF>
  40.         <CFIF NOT IsDefined("session.color")>
  41.             <CFSET session.color = "">
  42.         </CFIF>
  43.     </CFLOCK>
  44.     --------------------------------------------------------------->   
  45.     <!---------------------------------------------------------------- 
  46.     Use the application scope for the application variable. This
  47.     variable keeps track of the total number of turtlenecks sold. 
  48.     ------------------------------------------------------------------->
  49.     <!---------------------------------------------------------------- 
  50.     <CFLOCK SCOPE="Application" TIMEOUT="30" TYPE="Exclusive">
  51.         <CFIF NOT IsDefined("application.number")>
  52.             <CFSET application.number = 1>
  53.         </CFIF>
  54.     </CFLOCK>
  55.     <CFLOCK SCOPE="Application" TIMEOUT="30" TYPE="ReadOnly">
  56.         <CFOUTPUT>
  57.         E-Turtleneck is proud to say that we have sold #application.number#
  58.         <CFIF #application.number# NEQ 1>
  59.         turtlenecks 
  60.         <CFELSE>
  61.         turtleneck
  62.         </CFIF>
  63.         to date.
  64.         </CFOUTPUT>
  65.     </CFLOCK> 
  66. ------------------------------------------------------------------->    
  67. <!--- End of Application.cfm --->