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.
- function are_cookies_enabled() {
- document.cookie="testcookie";
- var cookies = ("testcookie" in document && (document.cookie.length > 0 || (document.cookie = "testcookie").indexOf.call(document.cookie, "testcookie") > -1));
- console.log('Cookie State: ' + cookies);
- return (cookies);
- }
- ...
- if (are_cookies_enabled() == false) {
- // give an alert cookies aren't being accepted
- }
What am I doing wrong?