Test for cross-browser cookie support

Test for cross-browser cookie support

Hi guys,

Trying to figure out the problem w/ this cross browser cookie code in Firefox, (it works in Safari, i.e. cookie state is true).  As far as I can tell from reading, this should work for ALL browsers, as navigator.cookies doesn't work properly in IE.
Keep getting false, when I know the cookie is in Firefox.

  1.  function are_cookies_enabled() {
  2.     document.cookie="testcookie";
  3.     var cookies = ("testcookie" in document && (document.cookie.length > 0 || (document.cookie = "testcookie").indexOf.call(document.cookie, "testcookie") > -1));
  4.     console.log('Cookie State: ' + cookies);
  5.     return (cookies);
  6.   }
  7. ...
  8. if (are_cookies_enabled() == false) {
  9.   // give an alert cookies aren't being accepted
  10. }

What am I doing wrong?