The log out page does not seem to be clearing the variables. What should I do.
The first thing we will do is create a table in your database called "Users" with the following fields:
|
Field
Name |
Type |
|
userID |
AutoNumber |
|
username |
text |
|
password |
text |
We will be creating 3 pages:
▪ loginCFC.cfc
▪ login.cfm
▪ logout.cfm
The first page that we will create is "loginCFC.cfc".
<cfcomponent name="LoginCFC">
<cfscript>
// call our internal initialize function
init();
</cfscript>
<cffunction name="init"
access="public">
<!--- initialize data for component --->
<cfparam
name="request.dsn"
default="loginCFC">
</cffunction>
<cffunction access="public"
name="verifyUser">
<!--- make sure username and password are required --->
<cfargument
name="getUsername"
type="string"
required="yes">
<cfargument name="getPassword"
type="string"
required="yes">
<!--- query the database for the username and password that were passed --->
<cfquery
name="verifyusername" datasource="#request.dsn#">
SELECT username
FROM Users
WHERE username = '#arguments.getUsername#'
AND password = '#arguments.getPassword#'
</cfquery>
<!--- return the result --->
<cfif verifyusername.recordCount>
<cfreturn verifyusername.username>
<cfelse>
<cfreturn
False>
</cfif>
</cffunction>
</cfcomponent>
Next we will create the ?login.cfm? page
<!--- Make sure form was submitted --->
<cfif structKeyExists(form,"verify")>
<cfinvoke component="loginCFC"
method="verifyUser"
returnVariable="verify"
getUsername="#form.username#"
getPassword="#form.password#">
</cfif>
<!--- Login Form --->
<cfform name="security"
method="post"
action="">
Username: <cfinput name="username"
type="Text"><br>
Password:<cfinput name="password"
type="password"><br>
<cfinput type="Submit" name="verify">
</cfform>
<!--- If login was successful tell user that the username and password were verified
successfully. If not, tell the user their username and/or password was wrong --->
<cfif isDefined("variables.verify")>
<cfif variables.verify NEQ 0>
Verified Successfully!
<cfelse>
Incorrect Username and/or Password!
</cfif>
</cfif>
Finally we will create the ?logout.cfm? page
<cfscript>
StructClear(variables);
</cfscript>
<cflocation url="login.cfm" addtoken="No">
The log out page does not seem to be clearing the variables. What should I do.
Sorry, I have never really used FuseBox.
Hi, is there a way to apply it to FuseBox 4.1? Thanks, great app!!