Skip to main content
Known Participant
March 24, 2008
Question

Question about Application.cfm ?

  • March 24, 2008
  • 2 replies
  • 354 views
Hi,

I use the following code to check if the user login

<cfif not IsDefined("Session.userLogin") >
<cflocation url="login.cfm" addtoken="no">
</cfif>

But the site is very slow when I add the three line code to application.cfm,why?

and how I can add the three line to all cfm files.

Thanks a lot

Mark
    This topic has been closed for replies.

    2 replies

    March 24, 2008
    Since this code is in your Application.cfm file it will attempt to redirect you to login.cfm even if you are already on login.cfm. Change your if statement to something like this...

    <cfif not IsDefined("Session.userLogin") and not FindNoCase("login.cfm", cgi.path_info)>

    This says "if the session var is not defined and the user is not on login.cfm, process the nested code".

    Hope that helps.
    - Chris
    Inspiring
    March 24, 2008
    i suspect you might have gotten yourself into an endless redirect loop
    if you have those 3 lines just like that in your Application.cfm...
    you see, if your user is not logged in, then he;s not logged in on
    login.cfm page either, which will fire the code and redirect to
    login.cfm, which will fire the code and redirect, which will... you get
    the picture, right?

    at the least you can change your first line to:
    <cfif getfilefrompath(cgi.script_name) neq 'login.cfm' AND not
    IsDefined("Session.userLogin") >

    as for your second question:
    to make this code run on every .cfm page, you put it in
    Application.cfm... which is what you have done already.

    hth

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/