The way I've done this in the past was to store the credentials on the flex client and re-authenticate the user with these using the CFLOGIN framework. This way the responsibility for continuing the session is on the flex side of things. This works with the RemoteObject.setRemoteCredentials(). Unfortunately you end up (unless someone else has a better idea) of doing the re-authentication in Application.cfc. But it does work. This way the app can stay up and running well beyond the session timeout. If you want an inactivity timeout there are ways to handle that in Flex.
On Tue, Mar 15, 2011 at 5:03 PM, Mary Jo Sminkey <[email protected]>wrote: > > Okay, so we have a flex application running on top of ColdFusion. Basically > going through CFCs as web services for whatever it needs. But I'm having a > hard time coming up with the best way to handle sessions. I don't really > store much in the session, other than just the user ID and whether they are > logged in or not. I need to handle the user authentication on the CF side > and then tell Flex the result. All easy enough when the app loads up. > > But I've been trying to make sure that on each CFC request, I am checking > that they are still logged in and authenticated. I do have some code to ping > CF and keep the session active, but just in case that isn't working, I need > to make sure they are still active. I've been playing around with the > onCFCRequest and got this working for the most part. If their session had > timed out, it will just re-authenticate them and make sure they're still an > active user before passing off the request to the CFC. Works great up to > this point. > > The problem I'm having is that if they aren't logged in, or if an error is > thrown inside a CFC and I have the event handler rethrow it, it's not > throwing it to Flex correctly. Instead of the error type of "FaultEvent" > that Flex accepts, it's throwing "Server.Processing" and instead of the > normal error details, I always get one that says "An exception occurred > while invoking an event handler method from Application.cfc. The method name > is: OnCfcRequest." The actual FaultEvent and details that I *should* be > getting are buried further down inside the fault that Flex is getting (in > extendedData.rootcause). So I'm not able to do any custom error handling in > Flex or show the user the Flex-based "login failed" message. The fault > handling worked fine before I added the onCFCRequest, so seems to be a bug > when you use this. > > Anyone else played with this new event handler method much yet with Flex > and find a solution for this? Or is there a better way of syncing sessions > between Flex and ColdFusion that I can look at instead? I'm just not sure of > a good way for Flex to know if the user is still logged in without running a > separate authentication check before every service call which seems kind of > kludgy. > > > -- Mary Jo > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:343061 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

