Skip to main content
Participant
October 8, 2006
Question

onSessionEnd Event does not fire

  • October 8, 2006
  • 1 reply
  • 501 views
Hello all,

So I have spent the day messing with CFMX7... upgrading to 7.0.2, trying different configurations in CF admin (use J2EE Session variables on/off etc....), using both Firefox and IE, and have not been able to get anything to work with onSessionEnd.

My little attempt to see if it works as documented was to create an application called: cfSession. It has two files, Application.cfc and Index.cfm. Index is just used to dump Application and Session variables. Basically, the onSessionEnd never gets called and the "activeSessions" variable in the Application context never gets decremented. The code is here so you can run it and see if you get the same results I have.

The big question... If you can make it work, can you please let me know how?

Thanks
    This topic has been closed for replies.

    1 reply

    Participant
    October 8, 2006
    First Question, does the code run outside of the function?

    I use on session end in one of my applications and surround the code in a cftry and then email myself the error if one occurs. But you need to test the code outside of Application.cfc first and be very confident that the code is not erroring.

    Kris Brixon
    http://www.brixontech.com
    ondisAuthor
    Participant
    October 9, 2006
    Hi Kris,

    Thanks for taking the time to look at my post. So, I did have a problem with the code I posted. Basically, too many cut and pastes from other functions to see if the code was working elsewhere. To execute, the "isDefined" section should look like this:

    if (isDefined("Arguments.ApplicationScope.Sessions.#sessId#")){
    Arguments.ApplicationScope.Sessions[#sessId#].end = sessionEnd;
    Arguments.ApplicationScope.Sessions[#sessId#].isLoggedIn = false;
    }

    I had forgotten to replace Application with Arguments.ApplicationScope and left off 'Sessons' in the isDefined argument causing to evaluate to false. The log entry code was fine.

    I fixed these, put it in a Try/Catch block and the onSessionEnd is just not being executed. The method I used to confirm this was to call the onSessionEnd directly from another method. I used onRequestEnd and of course it executes fine in that case.
    You can do that with the following code:

    <cfscript>
    onSessionEnd(Session,Application);
    </cfscript>

    What we know:
    We know the code executes correctly
    We know that CF is simply not calling the onSessionEnd function in Application.cfc.
    We know that CF is terminating the Session because the we continually get new Sessions: S1, S2, S3.... and can see them when the Session and Application contexts are dumped via cfdump tags in index.cfm. The cfSession.log file also confirms this as there is never a log entry for Session Termination.

    At this point I am perplexed. I think we need an Adobe ColdFusion guru to explain what is going on here as I am suspicious it is a Bug in CFMX7. I updated to 7.0.2 during the weekend hoping that would fix the problem.

    Thanks,
    Ondis