Open seowyanyi opened 9 years ago
Hey @seowyanyi ,
Currently there's no way to do this without clearing each cookie individually.
This is actually a tricky feature to add. The native JS cookies API (document.cookie
) will only expose a list of keys and values for set cookies - options like path, domain, and secure are not included. So while a cookie may have been set with a specific domain, there's no way to tell when examining the cookie later on.
The only possible way to implement a feature like this, would be to use a "shotgun" approach. Where, for each cookie, attempt to expire it with the passed in domain value. If the cookie was set under that domain, it would be successfully expired, otherwise nothing would happen.
This is definitely something to consider adding to the library.
https://github.com/p/delete-all-cookies does this (as well as clearing cookies for parent domains).
Is there a way to clear all cookies under a domain, for example when a user logs out?