Maintain Session State With Flex Upload To CF
Posted By : todd sharp Posted At : December 1, 2008 9:05 AM Posted In: Flex, ActionScript
6
I've started to dabble a bit in Flex/ActionScript lately, so I'm starting to pay attention to some more Flex/AS related posts via the aggregators. This morning a post to the Flex cookbook titled Why is session info (cookies) not sent when uploading files in Firefox caught my eye since I struggled with this issue a bit recently. The article explains why session state is not maintained when using FileReference.upload(), but it doesn't explain how to workaround the issue.
To workaround the issue when uploading to a ColdFusion server, the tactic that I have come up with is to pass the jsessionid into my Flex application (via Flash vars) and then pass the jsessionid along with my file upload by appending it to the target url. I'm not 100% sure this is the best solution (feel free to comment with other ideas or suggestions), but it serves the purpose of maintaining session state which allows me to do things like ensure that a valid, logged in user is performing the upload.


however, for file uploads through Flex (which I have done in the context of an ordering process), I typically deliver the file with additional form variables that specify what ought to happen; in my case it is an orderid.
You have a couple of competing issues here - connecting to your session state and security. Depending on what you need to happen, you might consider having your Flex ask for the upload destination and whatever else is needed from the CF side as an encrypted string and then deliver that string with the file ... that way your Flex pathway doesn't come back to haunt you (encryption & decryption remain server side so you shouldn't run into problems).
http://www.firemoss.com/post.cfm/Flex-Security-Ses...
http://www.danvega.org/blog/index.cfm/2008/7/31/Co...
The other thing I do is run a ping timer in my Flex/Air app that keeps the session alive on the server.