Skip to Content »

FlashApe » Flash File Upload and Session Cookies

 Flash File Upload and Session Cookies

  • April 4th, 2007
  • 9:00 pm

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).

8 People had this to say...

Gravatar

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).

Gravatar

actually, sorry for doublecomments, what you’re describing is the case in Firefox, while IE works fine.

[...] Flash doesn’t append session data to file uploads. [...]

Gravatar

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

Gravatar
  • BogdanEmil
  • November 23rd, 2007
  • 12:55 am

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!

Gravatar

It would be smarter to use postData (FileReference.postData property) for session ids.

Gravatar
  • rich
  • December 6th, 2007
  • 7:13 am

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.

Want your say?

* Required fields. Your e-mail address will not be published on this site


You can use the following XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>