Sam Farmer head shot

Sam Farmer

Growing up I never imagined I would play bass guitar for the Dave Matthews Band. And indeed it never happened.

But I have become a passionate and pretty good web developer.


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.

view plain print about
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}

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.7. Contact Blog Owner