tracker issue : CF-4195722

select a category, or use search below
(searches all categories and all time range)
Title:

onSessionEnd method is not called when using Redis as external session store.

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): / ext-user ()

Created: 10/09/2016

Components: Core Runtime, Session Management

Versions: 2016

Failure Type: Non Functioning

Found In Build/Fixed In Build: 2016,0,0,298074 / 2016.0.04.302324

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Windows 7 SP1 64-bit

Vote Count: 0

Listed in the version 2016.0.04.302561 Issues Fixed doc
Problem:
onSessionEnd method is not called when using Redis as external session store.

Method:
see comments section

test code:
<cfcomponent>
        <cfset this.name="redissession_lifecycle_test_app">
        <cfset this.sessionManagement=true>
        <cfset this.sessionTimeout=CreateTimeSpan(0,0,0,3)>
        <cfset this.applicationTimeout=CreateTimeSpan(0,0,0,5)>
        <cfset application.sessions_count = 0>

    <cffunction name="onApplicationStart">
        <cflog text="Application #this.name# intialized.. session count: #application.sessions_count#." log="Application" type="information" file="#this.name#">
    </cffunction>

    <cffunction name="onSessionStart">
        <cfset  application.sessions_count++>
        <cflog text="session started. session count: #application.sessions_count#." log="Application" type="information" file="#this.name#">
    </cffunction>

    <cffunction name="onSessionEnd">
        <cfargument name="session_scope" required="true"/>
        <cfargument name="application_scope" required="true"/>

        <cfset  application.sessions_count-->

        <cflog text="session terminated. ID: #session_scope.sessionid#. session count: #application.sessions_count#." log="Application" type="information" file="#this.name#">
        <cfdump var=#session_scope# label="in-session-end-func" output="console">
        <cfdump var=#application_scope# label="in-session-end-func-application" output="console">
    </cffunction>

    <cffunction name="onApplicationEnd">
        <cflog text="Application #this.name# terminated.. session count: #application.sessions_count#." log="Application" type="information" file="#this.name#">
    </cffunction>
</cfcomponent>

Result:
log :
with redis as session store:
"Severity","ThreadID","Date","Time","Application","Message"
"Information","http-nio-8500-exec-4","10/09/16","11:41:09","","C:\ColdFusion2016\expReGM\cfusion\logs\session_lifecycle_test_app.log initialized"
"Information","http-nio-8500-exec-4","10/09/16","11:41:09","SESSION_LIFECYCLE_TEST_APP","Application session_lifecycle_test_app initialized."
"Information","http-nio-8500-exec-4","10/09/16","11:41:09","SESSION_LIFECYCLE_TEST_APP","session start called. session count: 1"
"Information","scheduler-0","10/09/16","11:41:42","SESSION_LIFECYCLE_TEST_APP","Application session_lifecycle_test_app terminated."

with in-memory session store:
"Severity","ThreadID","Date","Time","Application","Message"
"Information","http-nio-8500-exec-2","10/09/16","11:58:57","","C:\ColdFusion2016\expReGM\cfusion\logs\redissession_lifecycle_test.log initialized"
"Information","http-nio-8500-exec-2","10/09/16","11:58:57","REDISSESSION_LIFECYCLE_TEST","Application redissession_lifecycle_test intialized.. session count: 0."
"Information","http-nio-8500-exec-2","10/09/16","11:58:57","REDISSESSION_LIFECYCLE_TEST","session started. session count: 1."
"Information","scheduler-0","10/09/16","11:59:08","REDISSESSION_LIFECYCLE_TEST","session terminated. ID: REDISSESSION_LIFECYCLE_TEST_3200_40126258294379cc-914D0318-0377-3CAB-15640ED761D30192. session count: -1."
"Information","scheduler-2","10/09/16","11:59:55","REDISSESSION_LIFECYCLE_TEST","Application redissession_lifecycle_test terminated.. session count: -1."

CF server console output:
Oct 9, 2016 11:58:57 AM Information [http-nio-8500-exec-2] - C:\ColdFusion2016\expReGM\cfusion\logs\redissession_lifecycle_test.log initialized
Oct 9, 2016 11:58:57 AM Information [http-nio-8500-exec-2] - Application redissession_lifecycle_test intialized.. session count: 0.
Oct 9, 2016 11:58:57 AM Information [http-nio-8500-exec-2] - session started. session count: 1.
Oct 9, 2016 11:59:08 AM Information [scheduler-0] - session terminated. ID: REDISSESSION_LIFECYCLE_TEST_3200_40126258294379cc-914D0318-0377-3CAB-15640
ED761D30192. session count: -1.
in-session-end-func - struct
cfid: 3200
cftoken: 40126258294379cc-914D0318-0377-3CAB-15640ED761D30192
sessionid: REDISSESSION_LIFECYCLE_TEST_3200_40126258294379cc-914D0318-0377-3CAB-15640ED761D30192
urltoken: CFID=3200&CFTOKEN=40126258294379cc-914D0318-0377-3CAB-15640ED761D30192

in-session-end-func-application - struct
applicationname: redissession_lifecycle_test
sessions_count: 1

Expected:
with external session store session termination should be recorded.
with in-memory session store, the session count should be 0, and not -1.

Workaround:
n/a

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4195722

External Customer Info:
External Company:  
External Customer Name:  
External Customer Email:

Attachments:

Comments: