title: Refused to set unsafe header "Cookie"
body: <pre><code>function sendToken():void{
      console.log("In sendToken();")
      var cookie_name="auth_token_seven";
      var xhr;
      var hash;
      if(!docCookies.getItem(cookie_name)){
          console.log("Token not found!");
          hash="8617f366566a011837f4fb4ba5bedea2b892f3ed8b894023d16ae344b2be5881";
          this.docCookies.setItem(cookie_name,hash,"/",4000, true);
          console.log("Token set");
          xhr= new XMLHttpRequest();
          xhr.open("POST","myurl", true);
          xhr.withCredentials=true;
          xhr.setRequestHeader("Cookie",cookie_name=hash);
          xhr.send();
      }
  
      else{
          console.log("Token found");
          hash=docCookies.getItem(cookie_name);
          console.log("getting Token");
          xhr= new XMLHttpRequest();
          xhr.open("POST", "myurl", true);
          xhr.withCredentials=true;
          xhr.setRequestHeader("Cookie", cookie_name=hash);
          xhr.send();
      }
  </code></pre>
  
  <p>Hi, I am using cookie.js to set a cookie when a user logins on my website.
  What I am trying to do, is to set a auth token inside the cookie whenever a user logins on my website, this cookie with the auth token, is sent to the server, whenever the user tries to access some features on my site.</p>
  
  <p>The problem, I am facing is, Chrome disallows the setting of cookie by showing an alert message <strong>Refused to set unsafe header "Cookie"</strong>.</p>
  
  <p>I looked at one of the links <a href="https://stackoverflow.com/questions/28255284/refused-to-set-unsafe-header-cookie-error-in-browser-yet-request-is-successful">Refused to set unsafe header &quot;Cookie&quot; error in browser yet request is successful</a>.
  I tried my way around , but it's still not working.</p>
  
  <p>Can anyone please suggest a solution.</p>