home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / cfcookie.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.6 KB  |  71 lines

  1. <!--- This example shows how to set a CFCOOKIE variable,
  2. and also how to delete that variable --->
  3.  
  4. <!--- First select a group of users who have entered
  5. comments into the sample database --->
  6. <CFQUERY NAME="GetAolUser" DATASOURCE="cfsnippets">
  7. SELECT   EMail, FromUser, Subject, Posted
  8. FROM     Comments
  9. </CFQUERY>
  10.  
  11.  
  12.  
  13. <HTML>
  14.  
  15. <HEAD>
  16. <TITLE>
  17. CFCOOKIE Example
  18. </TITLE>
  19. </HEAD>
  20.  
  21. <BODY bgcolor=silver>
  22.  
  23. <H3>CFCOOKIE Example</H3>
  24.  
  25. <!--- if the url variable delcookie exists,
  26. set the cookie's expiration date to NOW --->
  27.  
  28. <CFIF IsDefined("url.delcookie") is True>
  29.     <CFCOOKIE NAME="TimeVisited"
  30.     VALUE="#Now()#"
  31.     EXPIRES="NOW">        
  32.  
  33. <CFELSE>
  34. <!--- Otherwise, loop through the list of visitors,
  35. and stop when you match the string aol.com in the
  36. visitor's email address --->
  37.  
  38. <CFLOOP QUERY="GetAOLUser">
  39.     <CFIF FindNoCase("aol.com", "#Email#", 1) is not 0>
  40.         <CFCOOKIE NAME="LastAOLVisitor"
  41.         VALUE="#Email#"
  42.         EXPIRES="NOW" >        
  43.     
  44.     </CFIF>
  45. </CFLOOP>
  46.  
  47. <!--- If the timeVisited cookie is not set,
  48. set a value --->
  49.  
  50.     <CFIF IsDefined("Cookie.TimeVisited") is False>
  51.         <CFCOOKIE NAME="TimeVisited"
  52.         VALUE="#Now()#"
  53.         EXPIRES="10">
  54.     </CFIF>
  55. </CFIF>
  56. <!--- show the most recent cookie set --->
  57. <CFIF IsDefined("Cookie.LastAOLVisitor") is "True">
  58.     <P>The last AOL visitor to view this site was
  59.     <CFOUTPUT>#Cookie.LastAOLVisitor#</CFOUTPUT>, on
  60.     <CFOUTPUT>#DateFormat("#COOKIE.TimeVisited#")#</CFOUTPUT>
  61. <!--- use this link to reset the cookies --->
  62. <P><a href="cfcookie.cfm?delcookie=yes">Hide my tracks</A>
  63.  
  64. <CFELSE>
  65.     <P>No AOL Visitors have viewed the site lately.
  66. </CFIF>
  67.  
  68. </BODY>
  69.  
  70. </HTML>       
  71.