title: How to fix header manipulation cookies using JavaScript?
body: <p>My JavaScript code:</p>
  
  <pre><code>function CookieSetting(name, value) {
      var today = new Date();
      today.setTime( today.getTime() );
      var expires = 28;
      expires = expires * 1000 * 60 * 60 * 24;
      var expires_date = new Date( today.getTime() + (expires) );
      document.cookie = name+"="+escape( value ) +
      ( ( expires ) ?";
     domain="+window.location.hostname+";path=/;expires="+expires_date.toGMTString() : "" )
  }
  </code></pre>
  
  <p>It's working fine, but when I run the Fortify tool, it is showing this error:</p>
  
  <blockquote>
    <p>The method CookieSetting() includes unvalidated data in an HTTP response header.</p>
    
    <p>This enables attacks such as cache-poisoning  cross-site scripting  cross-user defacement 
     page hijacking  cookie manipulation or open redirect.</p>
    
    <p>Including unvalidated data in an HTTP response header can enable cache-poisoning  cross-site scripting, cross-user defacement, page hijacking, cookie manipulation or open redirect. </p>
  </blockquote>
  
  <p>How can I fix this?</p>