How to Create a Simple Cold Fusion Login - Example With Login Check
(Page 2 of 2 )
<!--- application.cfm -->
<cfapplication name = "myapplication"
sessionTimeout = #CreateTimeSpan(0, 0, 0, 60)#
sessionManagement = "Yes">
<cfif not IsDefined("LoggedIn")>
<cflocation url="login.cfm">
<cfelse>
<cfset LoggedIn="yes">
</cfif>
Login.cfm
The <cfif> tag above checks to see if a variable called LoggedIn was defined. If not, the user is redirected to login.cfm.
Below is a simple login.cfm file.
<!---login.cfm--->
<cfform name="loginform" action=”put name of page where the login is checked>
User Name: <cfinput type="text"
name="username"
required="yes">
Password: <cfinput type="password"
name="password"
required="yes">
<!--add in code to check login against database-->
<cfinput type=”Submit”>
</cfform>
This example uses the <cfform> tag to create a form with a text box and a password box.
The action would be a cold fusion template that would have a SQL query requests information from the database. If the user is authenticated, the variable LoggedIn would be set to “yes” and the user would be allowed access to the site.
If the user is not authenticated, they could be provided with a registration page.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |