title: Chrome Extension / Add a cookie automatically in the background
body: <p>I would like to develop a chrome extension to automatically add a cookie to a domain.</p>
  
  <p>I want my cookie to be added without user interaction to the extension;</p>
  
  <p>Adding my cookie will be done in the background (here in <code>persistent.js</code>).</p>
  
  <p>Is it possible to achieve this?</p>
  
  <p>I tested this:</p>
  
  <pre><code>function cookieinfo(){
      chrome.cookies.set({"name":"user","url":"http://mywebsite/","value":"myvalue"},function (cookie){
          console.log(JSON.stringify(cookie));
          console.log(chrome.extension.lastError);
          console.log(chrome.runtime.lastError);
      });
  }
  window.onload=cookieinfo;
  </code></pre>
  
  <p>But this script does not really work.</p>
  
  <p>Here is my <code>manifest.json</code>:</p>
  
  <pre><code>{
    "name" : "Cookie Demo",
    "version" : "1",
    "description" : "Cookie API",
    "permissions": ["cookies", "webRequest", "webRequestBlocking", "&lt;all_urls&gt;"],
    "browser_action": {
      "default_icon": "iconon128.png"
    },
    "background": { "scripts": ["persistent.js"], "persistent": true },
    "manifest_version": 2
  }
  </code></pre>
  
  <p>I am a beginner and I do not know everything about it ..</p>
  
  <p>Thanks in advence</p>