9 Replies Latest reply on Jul 3, 2006 10:29 PM by Wolf_van_Ween

    Cookies from flash to asp

      I have a flash movie that creates a cookie called "cart_data". I want to request the cookie in an asp page with the following code:
      tempArray = Request.Cookies("cart_data")

      the problem is, it doesn't work. I believe that the asp cannot find the cookie that was made by flash

      Is there a solution to this?
        • 1. Re: Cookies from flash to asp
          at_play Level 1
          Flash doesn't create cookies, like browsers do. It's similar but different. Flash Player does NOT store the "shared object"
          or "cookie" in the temp folder but in the Flash Player #Shared Objects folder within the Flash Player folder of Document and Setting folder within the Current Users Folder under Application Data -> Macromedia -> Flash Player -> #SharedObjects -> SXCBJSF -> local

          And then the file in many cases is not readable by human eyes and is NOT in a browser standard cookie format. Some are human readable but compare one to a cookie placed from a browser and you will see they are NOT the same.

          At least that is what I have discovered. If I am wrong, which is possible, someone let me know so I can update my knowledge on this.

          • 2. Re: Cookies from flash to asp
            muzila Level 1
            Well, if i cannot use cookies, what should i do. I previosly tried to use a query string:
            getURL(" http://www.custombrackets.com/scripts/cart.asp?cartArray="+_global.cartArray, "_self"); in flash
            tempArray = Request.QueryString("cartArray") in asp.

            but this only worked in firefox, and not in internet explorer.
            • 3. Re: Cookies from flash to asp
              Wolf_van_Ween Level 1
              So called Flash cookies and browser cookies (the ones set and retrieved by ASP) have nothing in common. Either use a shared object between two swfs on two separate webpages or send information from Flash into the containing page and have some javascript code there handling the cookie read/write.
              • 4. Re: Cookies from flash to asp
                Wolf_van_Ween Level 1
                What is cartArray? An Array? If so, how is it serialized? (changed into a string) Did you urlencode it?
                Generally the code you gave is ok, there is no reason why it shouldn't work in IE for a single piece of data, e.g. a number.
                • 5. Re: Cookies from flash to asp
                  muzila Level 1
                  here is the complete code i am using in flash and asp (i am sending a number array from flash to asp)
                  In Flash:getURL(" http://www.custombrackets.com/scripts/cart.asp?cartArray="+_global.cartArray, "_self");
                  (where cartArray is an array of numbers such as: cartArray = (12,33,128,222)

                  In ASP:
                  tempArray = Request.QueryString("cartArray")
                  tempArray = Split(tempArray, ",")
                  for j = 0 to uBound(tempArray)
                  if isNumeric(tempArray(j)) then
                  end if
                  end if
                  • 6. Cookies from flash to asp
                    Wolf_van_Ween Level 1
                    You rely far too much on implicit conversions.

                    In Flash create a
                    var cartString:String = _global.cartArray.join();
                    instead of _global.cartArray use escape(cartString) in the getURL call.

                    I think the Request.QueryString function of ASP does automatic url-decoding, but I'm not sure. Better look that up.


                    PS of course, you have a syntax error in your ASP code (double "end if"), but this is probably because you typed it from memory...
                    • 7. Cookies from flash to asp
                      muzila Level 1
                      the escape does not work, i had to use tempArray = unescape("cartString") in asp.

                      Now it does not work in firefox either. At least the querystring worked in firefox, but the excape works nowhere
                      • 8. Cookies from flash to asp
                        Wolf_van_Ween Level 1
                        I think you need to do a bit of "tracing" here and tell us the results. I would first make copy of the asp script and change it so that it only shows the query string.
                        This should be urlencoded, so the escape has to work.
                        Your query string should look like this:
                        using the example of (12,33,128,222) you gave above.
                        If it does look like this, the problem is in ASP or more generally on the server side
                        if it doesn't look like this, it's in Flash

                        Then you unescape this in ASP, split it into a tempArray, and Response.Write this array. (My suspicion is you get non-numeric values and this causes a problem with the next loop)

                        Then you do your loop and Response.Write in your addItem() function

                        Of course, if the problem is in Flash, we need to look somewhere else. But I don't think that's the case.

                        Good luck
                        • 9. Re: Cookies from flash to asp
                          Wolf_van_Ween Level 1
                          PS: I just tested this by hand: I entered above query string (both urlencoded=escaped and with commas) by hand into IE, and your asp script returned "Your shopping cart is empty". Did you change anything in between?
                          Before you play with Flash, make sure it works from the browser's adress bar first.