Set cookies in Flex URLRequest

2020-04-12 16:28发布

问题:

I'm trying to set a cookie in a Flex, but it doesn't seem to work. Am I doing something wrong? Is this possible? It seems like this should be simple.

var fileRef:FileReference;
// fileRef is configured

var cookieString:String = "my cookies";
var cookieHeader:URLRequestHeader= new URLRequestHeader("Cookie", cookieString);

var url:String = 'my url'; 
var request:URLRequest = new URLRequest(url); 
request.method = URLRequestMethod.POST; 
request.requestHeaders.push(cookieHeader);
fileRef.upload(request);

The problem I'm trying to solve is, I cannot make a authenticated web service request through OpenAm without using cookies, and I cannot figure out how to place the cookies in the Flex file upload request (well actually this works in IE, but is broken in Firefox and Chrome - I read that this is because IE uploads the file in the same browser thread while some other browsers spawn a new thread, and the cookie information does not get passed along).