The docs contain a nice reference to the new Application.CFC feature. One thing I think is missing is a simple diagram of the methods and what they expect and return. That information is in the docs, but what I want is a nice one page simple Application.cfc I can cut and paste. I also tend to forget what methods return what values, so such a reference would be handy.
So - I wrote up a simple CFC. I read the file in and then passed it to cfdocument, and voila - my Application.CFC reference was done. I'll be adding it to "My Tools" in a few moments.
Archived Comments
onSessionStart() returns a boolean, just like onApplicationStart() and onRequestStart()
OK... got a question on the session argument "appScope". Shouldn't this be application scope (beat myself on the head for missing that during the beta). Just asking.
I nice reason to have Interfaces? :)
Sean - the docs say it returns void:
http://livedocs.macromedia....
I thought it was boolean as well.
John: In onSessionEnd, you can't access APPLICATION directly. You access it via a passed in argument. It is a reference so mods to the value will affect the App scope.
OK... got a question on the session argument "appScope". Shouldn't this be application scope (beat myself on the head for missing that during the beta). Just asking.
Weird, yes, void it is... I just tried returning false to abort the session / request but it didn't work. That seems a little inconsistent...
This has always been one of my biggest beefs with MacroMedia, their documentation. It's either incomplete or doesn't exist.
The biggest thing was when CFMX (6 and 6.1, not 7) was release. We heard how wonderful it will be to run mulitple instances. But when the product was release there was no simple, complete documentation anywhere telling you how to set this up. You had to hunt around the internet to find instructions from other people. There still isn't an easy, straight forward document explaining clustering in CFMX.
Granted you don't need this documentation now since CFMX7 has the most wonderful instance manager (I'm in love with it). I would love to see something like this for CFMX6.1. Wonder if you could pull it out of 7 and throw it into 6.1... hmmmmm. ;)
Is it possible to redirect a user to a login page when their session times out using onSessionEnd?
Technically no. Remember that CF defines a session as "a period of activity". So while your session will expire, CF can't force your browser to go somewhere. (That isn't 100% true. You CAN use JavaScript code to detect X amount of time and move the user.)
What you would want to do instead is make onSessionStart push the user to the login page. Actually - what I'd do instead is use onRequestStart. Make it check for a logged in flag, and if false, push the user there.
Please excuse my ignorance. I thought that onsessionend executed code when a session ends( 20 min of inactivity). I was thinking of trying to put a cflocation tag in the onsessionend tag to relocate a user to a login page when the session expires. Is that what you understood from my last post? If so, I apologize and thanks for the help.
It does execute the code, but it does it on the server. It's not on your browser. Remember that CF is all server side. If you idle for 20 mins, CF can't force your browser to do anything.
No need to apologize though. :)
Thanks for your help. What a major brain cramp. It can not push information to the browser. I guess since my application uses Flash Comm, I could write a push script to detect inactivity and force the user's screen to redirect to the login page.
Thanks for your help.
The main point to remember here is that onApplicationEnd() and onSessionEnd() happen asynchronously - so there is no request and therefore no associated browser.