Skip to content

Instantly share code, notes, and snippets.

Created January 16, 2012 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1622352 to your computer and use it in GitHub Desktop.
Save anonymous/1622352 to your computer and use it in GitHub Desktop.
JavaScript to test whether or not cookies are enabled
function testCanWriteCookies() {
document.cookie = 'test=1';
var allCookies = document.cookie.replace(' ', '').split(';');
for (var i = 0; i < allCookies.length; i++) {
//var index = allCookies[i].indexOf('test=1');
//alert('index=' + index);
if (allCookies[i] == "test=1") {
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment