How to use ORM and onSessionEnd()
At 16applications I use ORM extensively. Recently I wanted to track when users sessions timed out which the onSessionEnd function in Application.cfc is perfect for.
onSessionEnd is interesting in that its not part of a standard ColdFusion request process which ORM is somewhat dependent on. In order to use ORM inside it I had to use ormFlush() to get changes to flush to the database.
1function onSessionEnd( SessionScope ) {
2 if ( structKeyExists( arguments.SessionScope, "loginTrackerId" ) ) {
3 var lt = entityload("loginTracker", {loginTrackerId=arguments.SessionScope.loginTrackerId}, true );
4 lt.setOutDT( now() );
5 lt.setTimedOut( true );
6 ormFlush();
7 }
8}
2 if ( structKeyExists( arguments.SessionScope, "loginTrackerId" ) ) {
3 var lt = entityload("loginTracker", {loginTrackerId=arguments.SessionScope.loginTrackerId}, true );
4 lt.setOutDT( now() );
5 lt.setTimedOut( true );
6 ormFlush();
7 }
8}

There are no comments for this entry.
Add Comment Subscribe to Comments