この辺りのサンプルの切り貼りなのですが、一応sessionEndも呼ばれているようでした。
何か違いがあるでしょうか?
http://help.adobe.com/ja_JP/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d4b.html
http://help.adobe.com/ja_JP/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d40.html
バージョンは「ColdFusion Server デベロッパー 10,0,16,293499」で確認しています。
■Application.cfc
<cfcomponent output="false"><cfprocessingdirective pageencoding="UTF-8" /><cfsetting enablecfoutputonly="yes">
<cfcontent type="text/html; charset=UTF-8">
<cfscript>
setencoding("URL", "UTF-8");
setencoding("FORM", "UTF-8");
</cfscript>
<cfset this.name = "sessionTest">
<cfset This.sessionmanagement = true>
<cfset This.clientmanagement = false>
<cfset This.setclientcookies = true>
<cfset This.setdomaincookies = false>
<cfset This.sessiontimeout="#createtimespan(0, 0, 5, 0)#">
<cffunction name="onApplicationStart">
<cfset Application.sessions = 0>
</cffunction>
<cffunction name="onSessionStart">
<cfscript>
Session.started = now();
</cfscript>
<cflock scope="Application" timeout="5" type="Exclusive">
<cfset Application.sessions = Application.sessions + 1>
</cflock>
<cflog file="#This.Name#" type="Information"
text="SessionStart #Session.sessionid# started. start: #Session.started# Active sessions: #Application.sessions#">
</cffunction>
<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>
</cfcomponent>
ところで、ややそれますが、CFのクラッシュ等まで考えるとSessionEndは確実に呼ばれるとは限らないと思いますので、DBなどの永続的な後始末をする場合は、何らかのリカバリ手段も必要なのかなと思います。
* Last updated by: kit on 6/12/2017 @ 8:55 PM *