I'd like to be able to logout the user. I can do this by calling wp_logout() on the server but if the user drops connection is there a way to log them out?

The wp_logout() method clears the cookies. Is there a way to do this on the client? Maybe like a clear all cookies (logout) for this domain or path.

More Info:
For example, say they are at school or at the library on a public computer and the connection drops (which happens a lot).

  • did you manage to resolve this issue? May 12, 2020 at 12:42
  • @SebastianScholle I think the answer below might have solved it but I can't recall now and I'm not on the project anymore. May 15, 2020 at 3:14

1 Answer 1


You should be able to combine the solutions in these answers to achieve what you are looking for. Keep checking and if the internet connection drops, clear the cookies.

https://stackoverflow.com/questions/10426851/quickest-way-to-check-internet-connectivity-in-js https://stackoverflow.com/questions/179355/clearing-all-cookies-with-javascript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.