Keep getting "Bad request" messages in browser after adding JS
Finally found the solution to my problem, in case anyone else makes the same mistake.

The problem with my cookie is this line from the code above:

var cookieName = 'Drupal-quicktabs-active-tab-id-' + wrapperID + 'nid='+ nid;


Cookie names cannot contain equal characters (or spaces, commas, semi-colons etc). That will create errors. So i simply changed "=" to "-" in my code line above, and the errors went away.