Search code examples
actionscript-3airadobeflash-builder

Is it possible to store cookies and share it through multiple StageWebView instances?


I have a Mobile Project inside Flash Builder using Flex 4.6 and AIR 3.3. In this project I have multiple views, and some of them have a StageWebView inside them to show some online content.

To be more specific I use the StageWebViewBridge project so that I can make the bridge between AS3 and Javascript.

But, some of the content shown in those StageWebViews sometimes need login information. Which, in a common browser, is stored in the current session.

Since those StageWebViews do not share the same session, is it possible that I keep the cookies responsible for the session in the memory and then share these cookies with all the StageWebViews?

This problem would easily be solved in C# with the CookieContainer class, along with the HttpWebRequest, so something similar would really be helpful.


Solution

  • Short answer... yes, in some instances.

    Long answer... no, not if you plan to keep your app browser and OS independent. AIR will share it's cookies with browsers that also use the default OS cookie mechanism, but that functionality can't really be relied on across clients. If you want your app to work in Firefox (or I believe Chrome), this isn't possible.

    Check out the top answer from: Cookies working in Flex but not in Air

    I've solved this problem by some hackish URL hash-tag nonsense where I hand my session from AIR to the web view, but this is obviously in an environment where I control both the AIR and web pieces of the project 100% (and security at this particular project isn't a huge concern).