Skip to main content
March 23, 2009
Question

Login Infinate Loop

  • March 23, 2009
  • 2 replies
  • 566 views
Using attached code to try and force login for directory however if I try to access any pages in the directory I get a infinate loop to login.cfm. Why is this?
    This topic has been closed for replies.

    2 replies

    Inspiring
    March 24, 2009
    i would probably change your code to something like:

    <cfapplication
    name ="mySecurePages"
    SessionManagement = "yes"
    SetClientCookies = "yes"
    SessionTimeout = "#CreateTimeSpan(0,1,0,0)#">

    <cfif structKeyExists(url,'clear')>
    <cfset structClear(session)>
    </cfif>

    <cfif
    getfilefrompath(cgi.script_name) neq "login.cfm"
    AND
    (structKeyExists(session,'accessAllowed') is false
    OR
    session.accessAllowed is false)>
    <cflocation url="login.cfm">
    </cfif>


    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    March 23, 2009
    PopcornCoder wrote:
    > <cfif structKeyExists(session,'accessAllowed') and session.accessAllowed is
    > true and cgi.script_name neq 'login.cfm'>
    > <cflocation url="#cgi.script_name#">
    > <cfelse><cflocation url="login.cfm"></cfif>

    IF 'accessAllowed' exits in session scope AND
    session.accessAllowed IS TRUE AND
    cgi.scrpt_name DOES NOT EQUAL 'login.cfm'
    THEN
    relocate page to cgi.scriptName
    ELSE
    relocate to login.crm

    SO if cgi.script_name equals 'login.cfm' the third part of the if
    condition is false and the page relocates to login.cfm and runs the test
    again. In which the third part of the if condition is false so the page
    relocates to login.cfm and runs the test again in which the third part
    of the if condition is false so the page relocates to login.cfm and runs
    the test again ....

    I think that gets the point across.

    A couple of notes:

    One this type of test is usually done on the onRequestStart method
    rather then the pseudo constructor of the Application.cfc.

    Two you probably want to include the desired file not relocate to it.
    I.E. <cfinclude...> rather then <cflocation...> as a relocation
    generates a new request rather then completes the one already started.

    HTH
    Ian
    March 23, 2009
    What then do you suggest the code is since I made some modifications and that still didn't work :-(
    March 23, 2009
    I also did this in a Application.cfm file