• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

requested scope session has not been enabled

Guest
Aug 26, 2014 Aug 26, 2014

Copy link to clipboard

Copied

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.

Views

2.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 04, 2014 Sep 04, 2014

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";

 

...

Votes

Translate

Translate
Guest
Aug 29, 2014 Aug 29, 2014

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 02, 2014 Sep 02, 2014

Copy link to clipboard

Copied

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 02, 2014 Sep 02, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 03, 2014 Sep 03, 2014

Copy link to clipboard

Copied

I confirmed I actually have all three check boxes checked. Cant remember what the other is, and I'm not home right now. But again both of the ones you said to make sure were checked, are.

Anything else you can think of? Thanks for the help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 03, 2014 Sep 03, 2014

Copy link to clipboard

Copied

Please confirm by actually opening the Coldfusion Administrator and checking it. Also check that the default values for timeout have sensible values. That is, no 0 times, for example. Then press the button to Submit Changes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 03, 2014 Sep 03, 2014

Copy link to clipboard

Copied

Add, if only just for completeness, the attribute applicationtimeout="#CreateTimeSpan(1,0,0,0)#".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 03, 2014 Sep 03, 2014

Copy link to clipboard

Copied

Ok I'll do both. Wish I had brought my laptop with me to work so I could confirm this now.

Anyway, I screenshot it and add that attribute this afternoon. Thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 03, 2014 Sep 03, 2014

Copy link to clipboard

Copied

Here is a screen of my admin and the session var settings I have.

cfAdmin.png

Let me add a screen of the actual error. Maybe its something else.

cfAdmin.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 03, 2014 Sep 03, 2014

Copy link to clipboard

Copied

Your description is more detailed, hence much clearer, now. The cause of the problem is that you fail to implement an Application file.

Delete the cfapplication tag from login_process.cfm and save the line

<cfapplication etc. etc.>

as the file Application.cfm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

I do have an application.cfm file. And the cfapplication is there.

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

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

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

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

<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>

But I had it named with a lower case application. Not sure if that matters. Nut when I tried to change it, I get a new error. So something changed.

cfAdmin.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

Name it Application.cfm not Application.cfc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

This thread has information that will help someone else in future. If you are satisfied, please mark the post that you consider to be the correct answer. If you find it necessary, add a further explanatory post, and mark that as the answer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

No I meant sublime seemed to have an issue saving application.whatever with a capital "A". Not that sublime was the root cause of my session enabled error.

Anyway, thanks for the help and I have marked this as solved and a correct solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 04, 2014 Sep 04, 2014

Copy link to clipboard

Copied

LATEST

It was too sublime for me to get it, for which I apologize.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation