[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

session scope getting wiped on CF9

I recently ported an app to CF9

I have an Application.cfc in a sub folder of the application, which sets some session variables.  When I access (or the browser accesses) a file in a folder ABOVE where the Application.cfc sites, all vars in the session scope get cleared.  I just can't work out what is happeing.

The files above have their own Application scopre. But it has a completely different to the one in the sub folder..

The App has worked fine for many years, and the only difference is that we are now running on cf9.

Has anyone else exprienced this issue?  Any ideas?

Many Thanks in advance.

0
Jay1607
Asked:
Jay1607
  • 7
  • 4
1 Solution
 
Brijesh ChauhanStaff IT EngineerCommented:
Can you post your CFC ? Are you accessing them with the same domain, I mean you are not trying to access them in a subdomain ?
0
 
Brijesh ChauhanStaff IT EngineerCommented:
Add this to your CFC, if not already in there, to log when the session ends

<cffunction name="onSessionEnd"> 
    <cfargument name = "SessionScope" required=true/> 
    <cfargument name = "AppScope" required=true/> 
    <cfset var sessionLength = TimeFormat(Now() - SessionScope.started, 
        "H:mm:ss")> 
    <cflock name="AppLock" timeout="5" type="Exclusive"> 
        <cfset Arguments.AppScope.sessions = Arguments.AppScope.sessions - 1> 
    </cflock> 
    <cflog file="#This.Name#" type="Information"  
        text="Session #Arguments.SessionScope.sessionid# ended. Length: #sessionLength# Active sessions: #Arguments.AppScope.sessions#"> 
</cffunction>

Open in new window

0
 
Jay1607Author Commented:
Thanks brijeshchauhan

I have attached the Application.cfc that is in the /Admin/ Folder.  This is where the session scope is being wiped.

I have also attached the Application.cfm that is in the root folder.  This is the Application file that would be getting triggered on those file calls that are wiping the scope of /Admin/Application.cff

Application.txt

Application.txt
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
Jay1607Author Commented:
OK, I added the onSessionEnd function to the CFC and ran through the issue, but no log was written.

I also logged each request in the onRequest function, which were getting written, but the log to be written in the onSessionEnd was not getting written.

I guess this means that the session isn't ending.. which kind of deepens the mystery I guess.

I'll have a bit more of a play with different events and see if I can narrow it down further.

Thanks again brijeshchauhan

Jason
0
 
Brijesh ChauhanStaff IT EngineerCommented:
I don't see session management enabled in your Application.cfc ?? Just add this in there

<cfset THIS.SessionManagement = true />
0
 
Jay1607Author Commented:
I wish you were right..

It is in there.. line 45

//Set up the application.
        this.Name = "asaAdmin#Phase#";
        this.ApplicationTimeout = CreateTimeSpan( 0, 1, 0, 0 );
        this.SessionManagement = true;
......
0
 
Jay1607Author Commented:
One thing i have noticed is that after my session scope vars have been wiped, the session_id is different from before.. which I guess indicates that the session is infact being reset.. I don't know why the log wasn't written..

That leaves the question.. what is resetting the session?? I can't find anything..

I also tried it on another cf9 server, and the problem is not there.  I thought maybe session storage, but the server that was working didn't have the problem whether storage was registry or cookie..

0
 
Jay1607Author Commented:
The plot thickens.. it is actually resetting both ways..



So /Application.cfm is resetting the session for the application scope below it.

AND /Admin/Application.cfc is resetting the session for the application scope above it.
0
 
Brijesh ChauhanStaff IT EngineerCommented:
What is you name the same in both Application.cfm and Application.cfc

this.Name = "asaAdmin#Phase#"; in CFC

 <cfapplication name="asa2#Phase#" sessionmanagement="Yes" clientmanagement="yes" setclientcookies="yes"> - IN CFM

what happens if you have them named the same ??
0
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
keep single application name otherwise it will not set the sessions up

and what value #Phase# is referring to, is it purely dynamic, i mean it changes every seconds
0
 
Jay1607Author Commented:
brijeshchauhan, have changed application name for each Application file to same name.  That has resolved the issue and the session is not being cleared.. which is good.

It kind of leaves the question though of why this happened, and should we be forced to use the same Application scope for embedded applications?  Application has been running with two seperate application scopes for years without problem, and seems to run fine on another CF9 install.  Is this potentially a bug in some versions of CF9, or is there a setting that we are missing?

Thanks for your help brijeshchauhan.

Jason
0
 
Jay1607Author Commented:
Thank you.  A relief to get this one resolved.

I'm still going to spend some time investigating why this occurred and will post anything I find.

Thanks again.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now