Brian asks:
I'm trying to use the onSessionEnd function within my Application.cfc. I have followed all the rules and syntax but cannot get it to work properly. I've read numerous threads, blogs, tutorials, etc. When using the object test method I receive this error..."Element APPSCOPE.USERDATA.ID is undefined in ARGUMENTS"
userData is a session structure I use throughout a user's "session". What I want to do is save any changes to this data (particularly a logout timestamp) when the user times out or closes the browser window without actually logging out. As for the latter, I realize I need to be using J2EE sessions.
Any ideas?
Welcome to the wonderful world of non-interactive debugging. By that I mean since the onSessionEnd event fires on the server only, and not in your browser, it is a real pain in the rear to debug. What I recommend in this case is a very slow, and very simple approach.
First off - do nothing, yes nothing, in your onSessionEnd. Be anal and ensure that a empty method isn't throwing an error. Of course it won't, but as I said, you want to take it slow. Once you confirm that is running ok, the safest thing to do is inspect the session data passed in. I'd first try this (and this assumes you named the session scope sessionScope):
<cflog file="myapp" output="The keys in the session scope are: #structKeyList(arguments.sessionScope)#">
If you see userData, than repeat this for arguments.sessionScope.userData.
By the way Brian, I noticed you said "appData". In my Application.cfc reference data, notice that both the Application and Session scope are passed in to onSessionEnd. Are you using the right argument? It sounds like you are examining the application data, and not the session data. Again, the structKeyList will help you debug this.