Home arrow ColdFusion arrow Page 2 - How to Create a Simple Cold Fusion Login
COLDFUSION

How to Create a Simple Cold Fusion Login


Secure your Cold Fusion application from unauthorized users using tips and code from this article. Learn about the <CFIF> tag and other ways to secure your site. In the login page, the user is required to enter a login and password. This page sends a SQL Query to a database to see if the user is an authorized user. If the user is authenticated, the variable is set, and access is granted.

Author Info:
By: Aaron Schaap
Rating: 3 stars3 stars3 stars3 stars3 stars / 57
February 25, 2004
TABLE OF CONTENTS:
  1. · How to Create a Simple Cold Fusion Login
  2. · Example With Login Check

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
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.

blog comments powered by Disqus
COLDFUSION ARTICLES

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials