Skip to main content
August 27, 2014
Answered

requested scope session has not been enabled

  • August 27, 2014
  • 2 replies
  • 3250 views

Trying to get a site login set up and I keep getting the above error. I have enabled session vars in the CF admin, and have used sessionmanagement in my cfapplication. Not sure what I've done wrong.

<cfapplication name="myApp" sessionmanagement="yes" setclientcookies="yes" sessiontimeout="#CreateTimeSpan(0,1,0,0)#">

<!--- Now define that this user is logged out by default --->

<CFPARAM NAME="session.allowin" DEFAULT="false" />

<CFPARAM NAME="session.userName" DEFAULT="" />

<!--- Now if the variable "session.allowin" does not equal true, send user to the login page --->

<!--- the other thing you must check for is if the page calling this application.cfm is the "login.cfm" page and the "Login_process.cfm" page since the Application.cfm is always called, if this is not checked the application will simply Loop over and over. To check that, you do the following call --->

<cfif session.allowin neq "true">

     <cfif  ListLast(CGI.SCRIPT_NAME, "/") EQ "login.cfm">

     <cfelseif ListLast(CGI.SCRIPT_NAME, "/") EQ "login_process.cfm">

     <cfelse>

         <!--- this user is not logged in, alert user and redirect to the login.cfm page --->

         <script>

             alert("You must login to access this area!");

             self.location="login.cfm";

         </script>

     </cfif>

</cfif>

Any help would be greatly appreciated.

    This topic has been closed for replies.
    Correct answer BKBK

    Ok so cfm was what I had originally. Still not sure what cause the original error, but in saving my application file as cfc (accidently) then back to cfm....for some reason, not sure why, sublime would default the capital A back to lower case. So that was throwing an error. Had to manually browse to the file and rename it Application.cfm and then open with sublime. Seems to be working now. Maybe  sublime issue, althought ive been using sublime for almost 2 years now and had no issues like this before.

    Thanks for the help!


    It's far from sublime I'm afraid. You simply seem to have used the cfapplication tag in Application.cfc. To be clear, the 2 alternatives are:

    Application.cfm

    <cfapplication name="myApp" applicationtimeout="#CreateTimeSpan(1,0,0,0)#" sessionmanagement="yes" setclientcookies="yes" sessiontimeout="#CreateTimeSpan(0,1,0,0)#">

    or else

    Application.cfc

    <cfcomponent>

        <cfscript>

            this.name = "myApp";

            this.applicationTimeout = "#createTimespan(1,0,0,0)#";

            this.sessionManagement = "yes";

            this.sessionTimeout = "#createTimeSpan(0,1,0,0)#";

            this.setClientCookies = "yes";

        </cfscript>

    </cfcomponent>

    I would again appeal to you to mark off the thread as correct. That serves as a pointer to others with similar issues.

    2 replies

    BKBK
    Community Expert
    Community Expert
    September 2, 2014

    You have to enable session use in the Coldfusion Administrator. In the Memory Variables page, check the boxes

    Enable Application Variables

    Enable Session Variables (when unchecked, CSRF protection is disabled)

    September 2, 2014

    Thanks BKBK. I think that's what I've already done, but I'll check when I get home. I might not have checked both boxes.

    August 29, 2014

    Any one have any ideas? Still trying to resolve this.