Skip to main content
August 12, 2008
Answered

Application.cfc / cflogin issues

  • August 12, 2008
  • 1 reply
  • 301 views
I have not used an Application.cfc before, but coming from a software development background, I embraced the idea wholeheartedly. However, I seem to be having a problem and it is either a misunderstanding of how the Application.cfc works, or a misunderstanding of what happens when I do a cflogin. I've posted this elsewhere and have not received any help, so I am hoping someone here can help.

I've pretty much lifted the cflogin logic directly from a sample on the Adobe website, with only the insertion of a db call making it different. What happens is that if you start with a fresh session, you can link to the login screen from the home page, enter the login, then the next page (to which the form posts) is empty. Now, if I go back to the home page (up one level in the directory), then request the login page, I see nothing again. Finally, if I change the address bar to point to my logout page, I get logged out, it returns me to the home page, and I can now link to the login page. So, it appears that once I am logged in, something very bad is happening. There must be something I am really not understanding about CFLOGIN. What am I missing? Note that the index page is one level higher in the directory structure from all the other pages I am referencing in this post, including the Application.cfc, and that they are all in the same directory. you can get to my home page at http://www.changent.com/rr/index.html. to login, use help/me (this will only last until i have an answer). To logout, go to http://www.changent.com/rr/app/logout.cfm. I've attached a copy of my Application.cfc and other templates. Your help is really appreciated!
    This topic has been closed for replies.
    Correct answer
    In your Application.cfc file, the logic in the method onRequestStart() is correct. This handles cflogin correctly.

    The problem for you is that you also implement onRequest()
    If you implement this method you must directly include the target page in order to view it.

    Or you can remove this method so that it is not implemented and the requested page will be processed.


    Description
    Runs when a request starts, after the onRequestStart event handler. If you implement this method, it must explicitly call the requested page to process it.

    Function syntax

    <cffunction name="onRequest" returnType="void">
    <cfargument name="targetPage" type="String" required=true/>
    ...
    <cfinclude template="#Arguments.targetPage#">
    ...
    </cffunction>

    1 reply

    Correct answer
    August 12, 2008
    In your Application.cfc file, the logic in the method onRequestStart() is correct. This handles cflogin correctly.

    The problem for you is that you also implement onRequest()
    If you implement this method you must directly include the target page in order to view it.

    Or you can remove this method so that it is not implemented and the requested page will be processed.


    Description
    Runs when a request starts, after the onRequestStart event handler. If you implement this method, it must explicitly call the requested page to process it.

    Function syntax

    <cffunction name="onRequest" returnType="void">
    <cfargument name="targetPage" type="String" required=true/>
    ...
    <cfinclude template="#Arguments.targetPage#">
    ...
    </cffunction>
    August 13, 2008
    Perfect!

    That sure was not intuitive. I cannot see why it would not just drop the the method if there is no logic in it.

    I appreciate it very much! You are a lifesaver!