Skip to content

Conversation

ryan-codingintrigue
Copy link

I like the idea of an enabled property for cookies as I do this check myself, but this implementation has a few flaws:

  • navigator.cookiesEnabled always returns true in IE9
  • On a page which has cookies enabled and has previously set cookies, the code will remove all those previously set values by overwriting the document.cookie
  • Perhaps this was intended, but the test value is left in the user's cookies if a test succeeds. If you need to check if cookies are enabled, you probably want to check on every load.

The suggested replacement uses $.cookies internal methods for setting a cookie, checking to see if it is set, then removing it again when finished.

Updated enabled check to allow for preexisting cookies to be maintained & IE9 compatibility
Moved `enabled` function to have access to internal methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant