title: Adobe Flex (mobile): StageWebView and HTML5 features: window.localStorage is null?
body: <p>I use FlashDevelop (great and free alternative to Flash Builder) that uses the (latest) open source Flex framework of Adobe.</p>
  
  <p>I want to develop an app for Android and iOS as well. In some parts I use an StageWebView to display content that i don't want to rewrite to flex AS3 code.</p>
  
  <p>In a nutshell: I am in an early stage of development and this is my first flex mobile app. In some parts it uses the HTML5 feature 'localStore' (part of object window in javascript) to store some data. But it seems that this feature is not available in the webkit browser of flex? I also want to know if this is a typical flex problem or does it also exists when the app will be deployed? The problem does not occur when loading the HTML part on a mobile device (for example in mobile safari). </p>
  
  <p>Also when the localStorage feature is not available it will switch back to cookies. But this is also not working correctly. In all other browsers no problemo, even in IE. 
  Result of cookie: <code>varname=undefined; expires=Thu, 03 May 2012 01:01:41 GMT.</code> </p>
  
  <p>What is going on?</p>
  
  <p>Here is some Javascript code:</p>
  
  <pre><code>// Picked up from: https://github.com/carhartl/jquery-cookie
  // Usage: http://www.electrictoolbox.com/jquery-cookies/
  jQuery.cookie = function (key, value, options) {
  
      // key and at least value given, set cookie...
      if (arguments.length &gt; 1 &amp;&amp; String(value) !== "[object Object]") {
          options = jQuery.extend({}, options);
  
          if (value === null || value === undefined) {
              options.expires = -1;
          }
  
          if (typeof options.expires === 'number') {
              var days = options.expires, t = options.expires = new Date();
              t.setDate(t.getDate() + days);
          }
  
          value = String(value);
  
          return (document.cookie = [
              encodeURIComponent(key), '=',
              options.raw ? value : encodeURIComponent(value),
              options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
              options.path ? '; path=' + options.path : '',
              options.domain ? '; domain=' + options.domain : '',
              options.secure ? '; secure' : ''
          ].join(''));
      }
  
      // key and possibly options given, get cookie...
      options = value || {};
      var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
      return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
  };
  </code></pre>
  
  <p>Local storage: </p>
  
  <pre><code>jQuery.locstore = function(key, val, opt ) {
        var ls = window.localStorage,
            j = window.JSON,  
            b = !( !ls || !j );
        if( !b )
         { return jQuery.cookie( key, val, opt ); }
  
        // set
       if( arguments.length &gt; 1 )
       { 
         var bRem = (val == null ),
             v = (bRem || typeof val == 'number' || typeof val == 'string')?val:j.stringify(val);
         if( bRem )
          { b = ls.removeItem(key); }
         else { b = ls.setItem(key, v); }
         return b;
       }
  
       // get
       var v = ls.getItem(key);
       if( v != null &amp;&amp; typeof val != 'number' )
        try { v=j.parse(v); } catch(e){}
       return v;
      };
  </code></pre>
  
  <p>I ask it here because i didn't find an answer on the net. Maybe someone give me a clue into the right direction to solve this?</p>