Rich Rodecker’s blog on flash, flex, actionscript, javascript, and php, with a dash of randomness
Flash File Upload and Session Cookies
Ran into this issue the other day, so I wanted to post this in case anyone else ran across it.
Normally, flash will send cookie data along with calls to the server using load vars, xml, etc. The one exception I seem to have found is with FileReference.upload(), which doesnt send them at all. I was sending the file to a java backend, and we found the solution to be to append the session cookie to the url, using a special syntax:
http://www.mysite.com/myPage.do;jsessionid=mySessionID?var1=value1&var2=value2
Notice that the ‘;jsessionid=’ part must be sandwiched between the file name and the query string in order to work properly (and not simply appended as a variable to the query string).
| Print article | This entry was posted by rich on April 4, 2007 at 9:00 pm, and is filed under flash. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 3 years ago
Yes, I just learnt that the hard way. What an annoying bug (or “missing feature”, in case someone says it’s The Way To Go).
about 3 years ago
actually, sorry for doublecomments, what you’re describing is the case in Firefox, while IE works fine.
about 3 years ago
Thanks for writing about this issue. I had this same problem, but I was using PHP instead of Java. The PHP solution is a little more complicated. I did a write up here:
Using Flash Upload with PHP and Symfony
about 2 years ago
I used your syntax:
file.upload(“http://www.mysite.com/UploadServlet;jsessionid=” + session + “?param1=” + param1 ..etc
but the session is still not sended (I get a new one in the upload servlet).
This is happening in Firefox (and probably in Safari – not tested).
Did you test the solution in Firefox? If it worked, the cookies on your browser were disabled?
THX!
about 2 years ago
It would be smarter to use postData (FileReference.postData property) for session ids.
about 2 years ago
this post was referencing sending session ids to java in flash player 8, which did not have a postData property at the time. I haven’t worked with this in a while, but if I remember correctly, we couldn’t simply pass in the sessionID as a variable anyway…we needed this specific syntax in order for java to properly access it.
about 2 years ago
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001675.html
about 2 years ago
this is so lame, flash needs to work with REAL http cookies…
about 9 months ago
If anyone want to encourage Adobe to fix this bug, here are the bug-tracker links for this issue:
https://bugs.adobe.com/jira/browse/FP-1044
https://bugs.adobe.com/jira/browse/FP-419
https://bugs.adobe.com/jira/browse/FP-201
https://bugs.adobe.com/jira/browse/FP-78
Unfortunately you have to create an account to view the issues, but there they are anyway.
about 6 months ago
This is 2010… so its 3 years after this post. I found this link and thought it might help…
http://swfupload.org/forum/generaldiscussion/977
Possible Cookie Bug Fix?: FileReference.load() instead of FileReference.upload()
about 6 months ago
Still no go… how lame adobe….