Does Flash Player transmit session cookies automatically?

后端 未结 4 643
温柔的废话
温柔的废话 2020-12-13 15:15

There\'s no access to the HTTP cookies from within a Flash movie, but I now have repeatedly read that Flash Player is supposed to take care of session cookies automatically.

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 15:31

    I'm sure this thread is dead by now, but I was recently faced a similar issue using ASP.NET and the FileUpload, and found a work-around based on some of the work here.

    I built a component that dynamically writes Flex objects to the page so they can be used in UpdatePanels. Message me if you want they code. To solve the above problem in pages where authentication cookies will need to be sent by URLRequest, I add the values in as flashVars.

    This code only works in my object, but you get the idea

    Dictionary flashVars = new Dictionary();     
    flashVars.Add("auth", Request.Cookies["LOOKINGGLASSFORMSAUTH"].Value);
    flashVars.Add("sess", Request.Cookies["ASP.NET_SessionId"].Value);
    myFlexObject.SetFlashVars(flashVars);
    

    Then in the Flex Object, check for the params

    if (Application.application.parameters.sess != null)
        sendVars.sess= Application.application.parameters.sess;
    if (Application.application.parameters.auth != null)
        sendVars.au= Application.application.parameters.auth;
    
    request.data = sendVars;
    request.url = url;
    request.method = URLRequestMethod.POST;
    

    Finally stuff the cookies in on global.asax BeginRequest

    if (Request.RequestType=="POST" && Request.Path.EndsWith("upload.aspx"))
    {
        try
        {
            string session_param_name = "sess";
            string session_cookie_name = "ASP.NET_SESSIONID";
            string session_value = Request.Form[session_param_name]; // ?? Request.QueryString[session_param_name];
            if (session_value != null) { UpdateCookie(session_cookie_name, session_value); }
        }
        catch (Exception) { }
    
        try
        {
            string auth_param_name = "au";
            string auth_cookie_name = FormsAuthentication.FormsCookieName;
            string auth_value = Request.Form[auth_param_name];// ?? Request.QueryString[auth_param_name];
    
            if (auth_value != null) { UpdateCookie(auth_cookie_name, auth_value); }
        }
        catch (Exception) { }   
    
    }
    

    Hope this help someone avoid the 6 hours I just spent addressing this. Adobe has closed the issue as unresolvable, so this was my last resort.

提交回复
热议问题