title: Log in to my web from a chrome extension
body: <p>I've got a web where logged in users can fill out a form to send information. I wanted my users to do this from a chrome extension too. I managed to get the form to sen information working but I only want to be logged in users to be able to do that. It's like a twitter or Springpad extension when the user first opens up the extension, it would have to log in or register. I saw the following answer at stack overflow: <a href="https://stackoverflow.com/questions/5354029/login-to-website-with-chrome-extension-and-get-data-from-it/5354526#5354526">Login to website with chrome extension and get data from it</a></p>
  
  <p>I gave it a try and put this code in background.html:</p>
  
  <pre><code>function login() {
      $.ajax({
          url: "http://localhost/login", type: "GET", dataType: "html", success: function() {
              $.ajax({
                  url: "http://localhost/login", type: "POST", data: {
                      "email": "me@alberto-elias.com",
                      "password": "mypassword",
                  },
              dataType: "html",
              success: function(data) {
                 //now you can parse your report screen
              }
              });
          }
      }); 
  }
  </code></pre>
  
  <p>In my popup.html I put the following code:</p>
  
  <pre><code>var bkg = chrome.extension.getBackgroundPage()
  $(document).ready(function() {
      $('#pageGaffe').val(bkg.getBgText());  
      bkg.login();        
  });
  </code></pre>
  
  <p>And on my server, which is in node.js, I've got a console.log that shows user information when he logs in, so I saw that when I load my extension, it does log in. The problem is how can I get the user to log in by itself, instead of manually putting my details in the code, how to stay logged in in the extension and when submitting the form, sending the user's details to the web.</p>
  
  <p>I hope I've managed to explain myself correctly.</p>
  
  <p>Thanks.</p>