title: Set Cookie with Javascript and sanitize value
body: <p>I need to set a cookie with javascript which I'm doing this with the following command:</p>
  
  <pre><code>document.cookie = name+"="+value;
  </code></pre>
  
  <p>My problem is that <code>value</code> is a string, which can contain any unicode-character.</p>
  
  <p>Is there a function which automatically replaces special characters (like <code>;</code>) - and if not, which characters are forbidden?</p>
  
  <p>Something like the "encodeURIComponent()"-Function for Get-Parameters would be perfect</p>