title: React Native WebView, how to store username and password
body: <p>i am creating a very simple app for android and iphone/ipad that uses only webview.
  How can i store username and password so the user would not have to type them in every single time. Thanks in advance.</p>
  
  <pre><code>import React, { Component } from 'react';
  import {
    AppRegistry,
    WebView
  } from 'react-native';
  
  export default class myapp extends Component {
    render() {
      return (
        &lt;WebView
          source={{uri: 'https://mysecretappurl.com'}}
        /&gt;
      );
    }
  }
  
  AppRegistry.registerComponent('myapp', () =&gt; myapp);
  </code></pre>
  
  <p>Thank you Fabian for a quick response.
  I got it solved with injectedJavascript and the data persist even if i close and relaunch the app both on android and ios. I got stuck as at first as tried to go with asyncstorage and reactnativ-webview-bridge but i failed to implement them due to my lack of knowledge.</p>
  
  <pre><code>import React, { Component } from 'react';
  import {
    AppRegistry,
    WebView
  } from 'react-native';
  
  export default class myapp extends Component {
    render() {
      let jsCode = `
          var cookie={};
          document.cookie.split('; ').forEach(function(i){cookie[i.split('=')[0]]=i.split('=')[1]});
          document.querySelector('#email').value=cookie['email'] || '';
          document.querySelector('#password').value=cookie['password'] || '';
          document.querySelector('#login button').onclick = function(){
              document.cookie = 'email='+document.querySelector('#email').value;
              document.cookie = 'password='+document.querySelector('#password').value;
          };
      `;
      return (
        &lt;WebView
          source={{uri: 'https://mysecretappurl.com'}}
          injectedJavaScript={jsCode}
        /&gt;
      );
    }
  }
  
  AppRegistry.registerComponent('myapp', () =&gt; myapp);
  </code></pre>