<!--- When the user starts the exam, set a session variable equal to the current time --->
<cfset Session.StartTime = Now()>
<!--- In your exam pages, use this code to check for the Session.StartTime variable. If it exists, check to see if the time stamp is more than 10 minutes old. If it is, delete it and redirect users to another page. If the variable doesn't exist, redirect them to an error page --->
<cfif isDefined("Session.StartTime")>
<cfif DateDiff("n",Session.StartTime,now()) gt 10>
<cfset tmp = StructDelete(Session,"StartTime")>
<cflocation url="ExamExpired.cfm">
</cfif>
<cfelse>
<cflocation url="YouMustStartExam.cfm">
</cfif>
Listing 2
<!--- Create a form with a textarea field for data entry.
Tell your users to put each entry on a separate line! --->
<cfform action="#cgi.script_name#" method="POST">
<textarea cols="35"
rows="10"
name="DomainNames"
wrap="off"></textarea>
<br>
<input type="Submit" value="Check Domains">
</cfform>
<!--- In your form action code, set a variable equal to the carriage return and line feed ASCII codes, then use that as the delimiter for your list --->
<cfif isDefined("Form.DomainNames")>
<cfset crlf = chr(13) & chr(10)>
<cfloop index="DomainName"
list="#Form.DomainNames#"
delimiters="#crlf#">
Execute code for each #DomainName#
</cfloop>
</cfif>
Listing 3
<!--- When inserting a password, use the Hash() function --->
<cfquery datasource="MyDataSource">
INSERT INTO Users (UserName, Password)
VALUES ('#Form.UserName#','#Hash(Form.Password)#')
</cfquery>
<!--- Use Hash() when changing passwords --->
<cfquery datasource="MyDataSource">
UPDATE Users
SET Password = '#Hash(Form.Password)#'
WHERE UserID = #Val(Session.UserID)#
</cfquery>
<!--- Use Hash() when validating a user --->
<cfquery datasource="MyDataSource" name="qCheckLogin">
SELECT UserID, Name
FROM Users
WHERE UserName = '#Form.UserName#'
AND Password = '#Hash(Form.Password)#'
</cfquery>
Listing 4
<!--- Use CFusion_Encrypt() to encrypt the data --->
<cfset EncryptedData = CFusion_Encrypt("Bruce Van Horn","MyKey")>
<!--- Use CFusion_Decrypt() to decrypt the data --->
<cfoutput>
#Variables.EncryptedData#<br>
#CFusion_Decrypt(Variables.EncryptedData,"MyKey")#
</cfoutput>