Skip to main content
March 30, 2009
Question

Application log In

  • March 30, 2009
  • 18 replies
  • 1308 views
Why does the attached code not cause people to redirect to the login.cfm page if there is no accessAllowed session variable? If they log in and are successfull it sets the variable accessAllowed = true which means the user is authenticated however it stopped working and the only thing I can see that's changed is this code.
    This topic has been closed for replies.

    18 replies

    Inspiring
    March 31, 2009
    that should work ok...

    just to rule out other possible issues, do this:

    in your onSessionStart method in Application.cfc add
    <cfset session.accessAllowed = false>

    then clear the cach and cookies and authenticated sessions in your
    browser and close it.

    if you have another browser installed - strat that one and try accessing
    your secured directory. ( if you do not have another browser insatlled -
    shame on you as a web developer! :) you can start the same browser
    again, but better after the session timeout period only...)


    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    March 31, 2009
    <cfoutput query="Getlisting">

    <CFIF Getlisting.recordcount EQ 1>
    <cfset Session.accessAllowed = true>
    <cfset Session.name = '#user_fname#'>
    <cfset Session.role = '#user_role#'>
    <CFLOCATION URL="index.cfm">
    <CFELSE>
    <cfset Session.accessAllowed = false>
    <CFLOCATION URL="login.cfm?login=failed">
    </CFIF>
    </cfoutput>
    <cfelse>
    <cfoutput>
    Inspiring
    March 31, 2009
    ok, that's better.

    now, where do you set the session.accessAllowed variable? post the code
    that sets it.

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    March 31, 2009
    ok if you try to access any page inside the "Application" then you can get to it and are not redirected to the login page. However if you log in log out by using clear=1 in the url and then try and go back in and access another page without logging in the logic then forces you to go to the login page before trying to access any other page.
    Inspiring
    March 31, 2009
    still not clear, sorry...

    what do you mean by 'if you try and access the directory for the first
    time it doesn't work'?

    what does not work? how do you expect it to work? how is the way it
    works different from what you expect?

    what do you expect to happen when one accesses your directory for the
    first time? what actually happens?

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    March 31, 2009
    Meaning if you try and access the directory for the first time it doesn't work but if you log in then log out by hitting clear it forces you to go to the login screen which is what we want. So my question is what do I need to modify in the code so that we can have it start working on that first access?
    Inspiring
    March 31, 2009
    > so how can we set it up to start out working

    ?? what do you mean? lost...

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    March 31, 2009
    ok that works only if I log in then put ?clear=1 at the end of the url so how can we set it up to start out working?
    Inspiring
    March 31, 2009
    sorry, my fault - bad copy/paste...

    change this line:

    <cfset var qsStruct = oRequest.getParameterMap()>

    to:

    <cfset var qsStruct = getPageContext().getRequest().getParameterMap()>

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    March 31, 2009
    Azadi:

    Received Variable oRequest is undefined error.