Over a million developers have joined DZone.

How to use ORM and onSessionEnd()

DZone's Guide to

How to use ORM and onSessionEnd()

Free Resource

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.

function onSessionEnd( SessionScope ) {    if ( structKeyExists( arguments.SessionScope, "loginTrackerId" ) ) {        var lt = entityload("loginTracker", {loginTrackerId=arguments.SessionScope.loginTrackerId}, true );        lt.setOutDT( now() );
        lt.setTimedOut( true );



Published at DZone with permission of Sam Farmer, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}