Macromedia coldfusion 4.5-cfml language reference User Manual
Chapter 1: ColdFusion Tags
31
do not have an EXPIRES attribute in a CFCOOKIE, the cookie set exists only as long as
the client browser is open. When the browser is closed, the cookie expires. It is never
written to the
the client browser is open. When the browser is closed, the cookie expires. It is never
written to the
cookies.txt
file.
Example
<!--- This example shows how to set a CFCOOKIE variable,
and also how to delete that variable --->
and also how to delete that variable --->
<!--- First select a group of users who have entered
comments into the sample database --->
<CFQUERY NAME="GetAolUser" DATASOURCE="cfsnippets">
SELECT EMail, FromUser, Subject, Posted
FROM Comments
</CFQUERY>
comments into the sample database --->
<CFQUERY NAME="GetAolUser" DATASOURCE="cfsnippets">
SELECT EMail, FromUser, Subject, Posted
FROM Comments
</CFQUERY>
<HTML>
<HEAD>
<TITLE>
CFCOOKIE Example
</TITLE>
</HEAD>
<HEAD>
<TITLE>
CFCOOKIE Example
</TITLE>
</HEAD>
<BODY bgcolor=silver>
<H3>CFCOOKIE Example</H3>
<H3>CFCOOKIE Example</H3>
<!--- if the URL variable delcookie exists,
set the cookie’s expiration date to NOW --->
<CFIF IsDefined("url.delcookie") is True>
set the cookie’s expiration date to NOW --->
<CFIF IsDefined("url.delcookie") is True>
<CFCOOKIE NAME="TimeVisited"
VALUE="#Now()#"
EXPIRES="NOW">
VALUE="#Now()#"
EXPIRES="NOW">
<CFELSE>
<!--- Otherwise, loop through the list of visitors,
and stop when you match the string aol.com in the
visitor’s email address --->
<!--- Otherwise, loop through the list of visitors,
and stop when you match the string aol.com in the
visitor’s email address --->
<CFLOOP QUERY="GetAOLUser">
<CFIF FindNoCase("aol.com", Email, 1) is not 0>
<CFCOOKIE NAME="LastAOLVisitor"
VALUE="#Email#"
EXPIRES="NOW" >
VALUE="#Email#"
EXPIRES="NOW" >
</CFIF>
</CFLOOP>
<!--- If the timeVisited cookie is not set,
set a value --->
set a value --->
<CFIF IsDefined("Cookie.TimeVisited") is False>
<CFCOOKIE NAME="TimeVisited"
VALUE="#Now()#"
EXPIRES="10">
VALUE="#Now()#"
EXPIRES="10">
</CFIF>
</CFIF>