Hello all, I'm new to CF and had an excellent experience posting here with my 
last issue, now I am having a problem making my secure login to my webpage 
work.  The issue seems to be (if I'm understanding correctly) that there is an 
infinite loop between my login.cfm and application.cfc.  I assume this is so 
because of the message Chrome is giving me, "The webpage has a redirect loop."  
The problem is I'm not understanding how to prevent it and still execute the 
logic to check the username/password.  My limited understanding of 
programming/development is working with one page and I think I may need a third 
page for this to work.  Here is my code:

<!--- Application.cfc --->

<cfcomponent output="false">
        <cfscript>
      this.name = "myApp";
      this.applicationTimeout = createTimeSpan(0,2,0,0);
      this.sessionManagement = TRUE;  // this line added to facilitate secure 
logins
  </cfscript>
      
  <cffunction name="onApplicationStart" returnType="boolean" output="false">
      <cfset StructClear(application)/>
      <cfset APPLICATION.name = "myApp">
      <cfset APPLICATION.dsn = "test">
      <cfif not IsDefined("LoggedIn")> <!---  this logic added to   --->
        <cflocation url="login.cfm">   <!--- facilitate secure login--->
      <cfelse>                         
        <cfset LoggedIn="Yes">
      </cfif>
      <cfreturn true>
  </cffunction>
</cfcomponent>

<!--- login.cfm --->

<html>
<title>Login Page</title>
<head>Login Page</head>
<body>
<cfform name="loginform" action="login.cfm">
Username: <cfinput type="text" name="username" required="yes">
Password: <cfinput type="password" name="password" required="yes">

<cfquery name="rsLogin" datasource="#application.dsn#">
  SELECT ClientName,ClientPass FROM CLIENTS WHERE ClientName LIKE 
#form.username#
</cfquery>

<cfif form.username EQ ClientName && form.password EQ ClientPass>
  <cfset session.LoggedIn = true>
<cfelse>
  <cfoutput> Incorrect Login.  Please ensure that Caps Lock is off and you 
typed 
             your username and password correctly.</cfoutput>
</cfif> 
<cfinput name="loginBtn" type="submit">
</cfform>
</body>

I found this example code on a different site and tried to integrate it into my 
existing codebase but it doesn't seem to work as described, if there is an 
example on this site or another that is better explained or laid out please 
feel free to post a link in your response.  I'm mostly looking for where I went 
wrong integrating it (or the other site in coding it???).  Looking forward to 
your responses, thank you in advance.  :) 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:353859
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to