Hi, I think that i am having an issue with onRequestStart in my 
Application.cfc. I am trying to write a login app, which I think that should 
work fine, but I can't get past the checkLogin page. I might be wrong but I 
think that it is due to the onRequestStart function. Any help would be great.

Since I clear the session in 1 minute, I don't think that this is the reason, 
and for the logout page, I was thinking that I can clear  everything with:
<<!--- logout.cfm--->
<cfset StructClear(Session)>
<!--- redirect the user to the home page--->

The database is set up correct, and I get no errors. I feel lost on this, as I 
can't get passed the form to login to the welcome page. I still need to make 
the form friendly with errors message if the login fails, but I want to get it 
working first!


thanks so much for any help,
Johnny

here is the code

<!--- Aplication.cfc--->
<cfcomponent displayname="Application" output="true" hint="Handle the 
application.">
        
        <cfset this.Name = "login" />
    
    <cfset this.SessionTimeout= CreateTimeSpan(0, 0, 1, 0) />
    <cfset thIs.ApplicationTimeout =  CreateTimeSpan( 0, 0, 1, 0 ) />
    
    <cfset this.SessionManagement = "yes" />
    <cfset this.clientmanagement="yes" />
    <cfset this.SetClientCookies = "no" />
        
    <cffunction name="onApplicationStart" output="no" returntype="void">
                <cfset REQUEST.dataSource ="my_DSN">
        
    </cffunction>
    
    <cffunction name="onRequestStart" output="no" returntype="void">
        <!---if the user is not login in, force them to log in--->
        <cfif not isDefined ("SESSION.auth.isLoggedIn")>
                <!---if the user is submitting the "login" form--->
            <!---include the "Login Check" to validate the user--->
            <cfif isDefined("FORM.userLogin")>
                <cfinclude template="loginCheck.cfm">
            </cfif>
            <cfinclude template="loginForm.cfm">
            <cfabort>
        </cfif>
    </cffunction>
</cfcomponent>        

<!--- index.cfm--->
<cfquery name="getUser" datasource="myDSN">
        SELECT user_id, userName, userPassword
    FROM users
</cfquery>

<cfoutput query="getUser">
        Welcome #getUser.userName#
</cfoutput>

<!---loginForm.cfm--->
<!---
        Filename - loginForm.cfc
        Created by - John Barrett ([email protected])
        Reason - the main loginForm for the application(included in the main 
Application file)
--->


<!---if the user is submitting the "login" form--->
<!---include the "Login Check" to validate the user--->
        <cfif isDefined("FORM.userLogin")>
        <cfinclude template="loginCheck.cfm">
    </cfif>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Please login</title>
</head>

<body>
        <!---start the login form--->
    <cfform action="loginCheck.cfm" name="loginForm" method="post">
        
        <cfinput type="hidden" name="userName_required" /> 
        <cfinput type="hidden" name="userPassword_required" />
        
       
        <table border="0">
                <tr>
                <td>username</td>
                <td>
                                        
                    <cfinput
                        type="text"
                        name="userName"
                        message="Please type you username first!"
                        required="yes" id="userName"
                        value=""
                        size="20"
                        maxlength="100"
                    > 
                </td> 
           </tr>  
           <tr>
                        <td>password</td>
                <td>
                                        
                    <cfinput
                        type="password"
                        name="userPassword"
                        size="12"
                        value=""
                        maxlength="100"
                        required="yes"
                        message="Please type you password first!"
                    > 
                </td> 
           <tr>
                <td>
                        
                    <cfinput type="submit" name="Submit" id="Submit" 
value="Submit">
                </td>
           </tr>
           </tr>
        </table>
    </cfform>
                    

</body>
</html>


<!---LoginCheck.cfm--->
<cfquery name="getUser" datasource="my_DSN">
        SELECT user_id, userName, userPassword
    FROM users
    WHERE userName= '#FORM.userName#'
    AND userPassword= '#FORM.userPassword#'
</cfquery>

<!--- if the user name and password are correct--->
<cfif getUser.recordcount eq 1>
        <!--- remember user's logged in status --->
        <!--- write user_id & userName in stucture--->
        <cfset SESSION.auth = structNew()>
        <cfset SESSION.auth.isLoggedIn = "yes">
        <cfset SESSION.user_id = getUser.user_id>
        <cfset SESSION.userName = getUser.userName>
        
    <!--- Now that the user is loggin, wend them to the index page--->
        <cflocation url="index.cfm">
</cfif>
                

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4993
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to