<!--- This example shows how to set a CFCOOKIE 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>



<HTML>

<HEAD>
<TITLE>
CFCOOKIE Example
</TITLE>
</HEAD>

<BASEFONT FACE="Arial, Helvetica" SIZE=2>
<BODY  bgcolor="#FFFFD5">

<H3>CFCOOKIE Example</H3>

<!--- if the url variable delcookie exists,
set the cookie's expiration date to NOW --->

<CFIF IsDefined("url.delcookie") is True>
	<CFCOOKIE NAME="TimeVisited"
	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 --->

<CFLOOP QUERY="GetAOLUser">
	<CFIF FindNoCase("aol.com", Email, 1) is not 0>
		<CFCOOKIE NAME="LastAOLVisitor"
		VALUE="#Email#"
		EXPIRES="NOW" >		
	
	</CFIF>
</CFLOOP>

<!--- If the timeVisited cookie is not set,
set a value --->

	<CFIF IsDefined("Cookie.TimeVisited") is False>
		<CFCOOKIE NAME="TimeVisited"
		VALUE="#Now()#"
		EXPIRES="10">
	</CFIF>
</CFIF>
<!--- show the most recent cookie set --->
<CFIF IsDefined("Cookie.LastAOLVisitor") is "True">
	<P>The last AOL visitor to view this site was
	<CFOUTPUT>#Cookie.LastAOLVisitor#</CFOUTPUT>, on
	<CFOUTPUT>#DateFormat(COOKIE.TimeVisited)#</CFOUTPUT>
<!--- use this link to reset the cookies --->
<P><a href="cfcookie.cfm?delcookie=yes">Hide my tracks</A>

<CFELSE>
	<P>No AOL Visitors have viewed the site lately.
</CFIF>

</BODY>

</HTML>       
