I didn’t use that code but I was able to confirm the problem with the very simple code at the end (two files). The code logs all onSessionStart(), onSessionEnd(), onRequestStart(), onRequestEnd() and onRequest() calls in Application.cfc.
I set the session timeout to one minute, I didn’t want to wait too long.
I accessed the site at 20:10:55 and a session starts (first bold line). At 20:12:12 I access the form again (second bold line). A new session starts. At 20:12:14 I save the form, which sets the session variable (“who”) to “aaa”. I don’t touch the site for another 1 minute and 6 seconds, which is 20:13:20 (third bold line). I access the form and set the session variable to “bbb”.
At that same time a new session starts, which is expected. After all one minute has passed. However, you can see from the logs that the initial session (started at 20:12:12) never ended.
This is what is happening in our full fledged app. With the first session not ending, we are not able to clean up after that session.
“INFO”,“ajp-nio-8009-exec-3”,“12/08/2022”,“20:10:55”,“”,“Application STARTING”
“INFO”,“ajp-nio-8009-exec-3”,“12/08/2022”,“20:10:55”,“”,“Session STARTING”
“INFO”,“ajp-nio-8009-exec-3”,“12/08/2022”,“20:10:55”,“”,“Request STARTING for at /index.cfm.”
“INFO”,“ajp-nio-8009-exec-3”,“12/08/2022”,“20:10:55”,“”,“REQUEST for at /index.cfm”
“INFO”,“ajp-nio-8009-exec-3”,“12/08/2022”,“20:10:55”,“”,“Request ENDING for .”
“INFO”,“ajp-nio-8009-exec-5”,“12/08/2022”,“20:12:12”,“”,“Session STARTING”
“INFO”,“ajp-nio-8009-exec-5”,“12/08/2022”,“20:12:12”,“”,“Request STARTING for at /index.cfm.”
“INFO”,“ajp-nio-8009-exec-5”,“12/08/2022”,“20:12:12”,“”,“REQUEST for at /index.cfm”
“INFO”,“ajp-nio-8009-exec-5”,“12/08/2022”,“20:12:12”,“”,“Request ENDING for aaa.”
“INFO”,“ajp-nio-8009-exec-6”,“12/08/2022”,“20:12:14”,“”,“Request STARTING for aaa at /index.cfm.”
“INFO”,“ajp-nio-8009-exec-6”,“12/08/2022”,“20:12:14”,“”,“REQUEST for aaa at /index.cfm”
“INFO”,“ajp-nio-8009-exec-6”,“12/08/2022”,“20:12:14”,“”,“Request ENDING for aaa.”
“INFO”,“ajp-nio-8009-exec-8”,“12/08/2022”,“20:13:20”,“”,“Session STARTING”
“INFO”,“ajp-nio-8009-exec-8”,“12/08/2022”,“20:13:20”,“”,“Request STARTING for at /index.cfm.”
“INFO”,“ajp-nio-8009-exec-8”,“12/08/2022”,“20:13:20”,“”,“REQUEST for at /index.cfm”
“INFO”,“ajp-nio-8009-exec-8”,“12/08/2022”,“20:13:20”,“”,“Request ENDING for bbb.”
After some time, I go back and open the log again. Ah, I can see a session ending later on. This line now appears at the end of the log.
“INFO”,“Thread-125”,“12/08/2022”,“20:14:44”,“”,“Session ENDING for bbb.”
Here are the two files. One is application.cfc. The other is the index.cfm where we simply set a session variable.
APPLICATION.CFC
<CFCOMPONENT>
<CFSET This.ClientManagement = false>
<CFSET This.SessionManagement = true>
<CFSET This.sessiontimeout = CreateTimeSpan(0,0,1,0)>
<CFSET This.Name = "TestApp">
<CFFUNCTION name="onApplicationStart" RETURNTYPE="boolean">
<CFLOG TEXT="Application STARTING" FILE="#This.Name#" TYPE="Information">
<CFRETURN true>
</CFFUNCTION>
<CFFUNCTION name="onApplicationEnd" RETURNTYPE="void">
<CFARGUMENT NAME="AppScope" REQUIRED=true />
<CFLOG TEXT="Application ENDING" FILE="#This.Name#" TYPE="Information">
</CFFUNCTION>
<CFFUNCTION name="onSessionStart" RETURNTYPE="void">
<CFSET Session.who = CreateUniqueId()>
<CFLOG TEXT="Session STARTING for #Session.who#" FILE="#This.Name#" TYPE="Information">
</CFFUNCTION>
<CFFUNCTION NAME="onSessionEnd" RETURNTYPE="void">
<CFARGUMENT NAME="SessionScope" REQUIRED=true />
<CFARGUMENT NAME="AppScope" REQUIRED=true />
<CFSET w = "">
<CFIF IsDefined( "Arguments.SessionScope.Who" )>
<CFSET w = Arguments.SessionScope.Who>
</cfif>
<CFLOG TEXT="Session ENDING for #w#." FILE="#This.Name#" TYPE="Information">
</CFFUNCTION>
<CFFUNCTION name="onRequestStart">
<CFARGUMENT NAME="targetPage" TYPE="String" REQUIRED=true/>
<CFSET w = "">
<CFIF IsDefined( "Session.who" )>
<CFSET w = Session.who>
</cfif>
<CFLOG TEXT="Request STARTING for #w# at #Arguments.targetPage#." FILE="#This.Name#" TYPE="Information">
</CFFUNCTION>
<CFFUNCTION NAME="onRequestEnd">
<CFSET w = "">
<CFIF IsDefined( "Session.who" )>
<CFSET w = Session.who>
</cfif>
<CFLOG TEXT="Request ENDING for #w#." FILE="#This.Name#" TYPE="Information">
</CFFUNCTION>
<CFFUNCTION NAME="onRequest" RETURNTYPE="void">
<CFARGUMENT NAME="targetPage" TYPE="string" REQUIRED="true"/>
<CFSET w = "">
<CFIF IsDefined( "Session.who" )>
<CFSET w = Session.who>
</cfif>
<CFLOG TEXT="REQUEST for #w# at #Arguments.targetPage#" FILE="#This.Name#" TYPE="Information">
<CFINCLUDE TEMPLATE="#Arguments.targetPage#"> <!--- Continue to the page. --->
</CFFUNCTION>
</CFCOMPONENT>
INDEX.CFM
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Hello</h1>
Time is <cfoutput>#Now()#</cfoutput>.
</body>
</html>