Title: Logout doesn&#8217;t always work
Last modified: February 9, 2021

---

# Logout doesn’t always work

 *  Resolved [devgains](https://wordpress.org/support/users/devgains/)
 * (@devgains)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/)
 * Hi,
 * I’ve been using this plugin for a few weeks but some users are having issues 
   with the logout function, it doesn’t always seem to work.
 * When trying in a private/incognito window, the function will work on the same
   machine.
 * It appears that the ipbl_*currentusername* cookie does not always get set, I 
   have been able to recreate the issue by using the following steps:
 * * User automatically logs in to the page using IPBL
 * * User uses IPBL logout function [siteurl/wp-admin/options-general.php?page=ip-
   based-login&no_login=15] – works as intended.
 * * Delete cookie for ipbl_currentusername
 * * Browse back to the site, user is logged back in automatically with IPBL.
 * * Try to use the logout again – user is simply redirected back to the homepage
   instead of the login screen.
 * As mentioned this works in a private window, or if the browser cache is completely
   cleared. I’m thinking something is getting stuck or conflicting, but I’m not 
   entirely sure what.
 * Any ideas?
    -  This topic was modified 5 years, 3 months ago by [devgains](https://wordpress.org/support/users/devgains/).
    -  This topic was modified 5 years, 3 months ago by [devgains](https://wordpress.org/support/users/devgains/).

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14050836)
 * Hi,
 * I tried to replicate the issue with the steps you provided and at the 2nd step
   itself i.e. :
    * User uses IPBL logout function [siteurl/wp-admin/options-general.
   php?page=ip-based-login&no_login=15] – works as intended.
 * After clicking on this link the user is redirected to the home page only.
 * Are you redirected to the login page ?
 * The code is written to redirect to the home page after clicking on the “Disable
   auto login” links.
 *  Thread Starter [devgains](https://wordpress.org/support/users/devgains/)
 * (@devgains)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14083168)
 * Hi,
 * On that step I am redirected to the login page as I would expect.
 * Though for some users this doesn’t work at all, I am able therefore able to recreate
   the problem they have by deleting the ipbl_username cookie on my own machine.
 *  Thread Starter [devgains](https://wordpress.org/support/users/devgains/)
 * (@devgains)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14084617)
 * Sorry, it’s probably worth mentioning that the we force all users to login on
   the site I am experiencing this issue on, hence why I am mentioning the login
   screen rather than the homepage as users who are not logged in will be directed
   to the login screen.
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14093972)
 * Hi,
 * We have just released v2.0.3 which will now redirect to login page after setting
   the no_login cookie.
 *  Thread Starter [devgains](https://wordpress.org/support/users/devgains/)
 * (@devgains)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14104767)
 * I’m afraid that hasn’t fixed my problem.
 * Perhaps my explanation was not great?
 * It doesn’t matter where your plugin redirects to after setting the cookie, what
   matters is that the session is actually terminated but this doesn’t always happen.
 * I can still recreate the issue. I will try and explain it simpler.
 * I have a webpage that requires all users to login.
    If they logon from specific
   IP addresses used with this plugin they are logged in as a subscriber automatically.
 * Some users need to login as an admin, so they use the logout link [wp-admin/options-
   general.php?page=ip-based-login&no_login=15]
 * When clicking this we would expect them to be returned to the login page as there
   existing session has been terminated and they now need to login.
    At the login
   page, I can see the IPBL_username no_login cookie has been set.
 * In order to recreate the problem my users experience, I DELETE this cookie, then
   try browsing to my site again.
 * IPBL see’s that no cookie is set, and logs the user in automatically.
 * I have a code in my themes function file that sets the logout button to the ipbl
   link below if the user is logged in with IPBL.
 * From this point, the logout link [wp-admin/options-general.php?page=ip-based-
   login&no_login=15] essentially does nothing whenever you click on it. No further
   cookie is set and the user cannot login as another user.
 * I think what is happening is the browser is clearing cookies on a scheduled basis
   which is then causing the problem for my users.
 * Can you try the steps I have listed as I can recreate the problem every time?
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14105900)
 * Opps. I thought that would resolve the issue and had marked the thread as resolved.
   I have marked the thread as not resolved again.
 * Regarding the issue I tried to replicate using the steps you provided but could
   not replicate the issue.
 * 1. I used the no_login link to disable login which set a cookie and logged the
   user out.
    2. I then deleted the cookie and I was able to login to the account
   again with IPBL. 3. Then I again used the no_login link to disable the login 
   and it took me to the login page and I was able to login with another user account
   since I was not auto logged in using IPBL.
 * Which browser are you using ?
 * If you could create a video of your screenshare and post it here it will help
   me to replicate exact same steps.
 *  Thread Starter [devgains](https://wordpress.org/support/users/devgains/)
 * (@devgains)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14105996)
 * I mainly use Firefox but the issue is the same in Chrome.
 * Thank you for looking into this, I’ve captured a quick video here which hopefully
   helps.
 * [https://drive.google.com/file/d/1ZIRbA7Cy7zmfGwvdDInoMLLP_ZCuZPmL/view?usp=sharing](https://drive.google.com/file/d/1ZIRbA7Cy7zmfGwvdDInoMLLP_ZCuZPmL/view?usp=sharing)
 * Also, bare in mind, my users are not taking these steps. They just contact me
   when they have the problem and these are the steps I take to recreate the issue.
    -  This reply was modified 5 years, 2 months ago by [devgains](https://wordpress.org/support/users/devgains/).
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14126543)
 * Hi,
 * Sorry for the delay.
 * I am unable to view the video.
 * It seems you need to change permission to be able to access to anyone with the
   link.
 *  Thread Starter [devgains](https://wordpress.org/support/users/devgains/)
 * (@devgains)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14126702)
 * No worries, sorry about that. I uploaded it on vimeo too
 * [https://vimeo.com/517117238](https://vimeo.com/517117238)
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14126811)
 * Hi,
 * I checked this again following the same steps you provided and I was not able
   to replicate the issue. The logout works fine even the 2nd time.
 * I think the issue could be due to some other plugin conflicting and returning
   without executing the IP Based Login function.
 * Do you have a DEV site where you are able to replicate this issue ? We will be
   able to upload some debugging code and debug faster.
 *  Thread Starter [devgains](https://wordpress.org/support/users/devgains/)
 * (@devgains)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14127194)
 * I do have a dev site but the site is only accessible internally. Is there anything
   in particular you would look for in debugging or any code I could add myself?
 * I will disable all the other plugins on my dev version and try to find the conflicting
   one, I would have tried this before but was confident we shouldn’t have anything
   else that hooks to the logout.
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14131565)
 * Hi,
 * Actually the function is not triggered in logout hook but it is triggered in 
   the plugins_loaded hook which could be hooked by several plugins.
 * In order to debug this you can add some debugging code in following file :
    ip-
   based-login/init.php
 * In the function ip_based_login_update_check Line no : 83 and check if that debug
   code is executed or not.
 *  Thread Starter [devgains](https://wordpress.org/support/users/devgains/)
 * (@devgains)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14151989)
 * Hello,
 * I couldn’t get to the bottom of this but I have managed to solve it with a workaround.
 * I am just using JS to post the data to the logout url and then redirect once 
   the response comes back.
 * I did try some debug code, ip_based_login_update_check runs every time. It looks
   like the problem was being caused by the $_REQUEST variable being empty on occasion,
   but I was pulling my hair out trying to find the cause, gave up in the end.
 * Hopefully this advice helps somebody.
 * Happy for the topic to be closed now, thanks for all your support.
 *  Plugin Author [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * (@brijeshk89)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14153257)
 * Hi,
 * Sorry we could not get to the root of problem to solve the issue.
 * Thank you for sharing the workaround.
 * As per your request we are closing this topic.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Logout doesn’t always work’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/ip-based-login.svg)
 * [IP Based Login](https://wordpress.org/plugins/ip-based-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ip-based-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ip-based-login/)
 * [Active Topics](https://wordpress.org/support/plugin/ip-based-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ip-based-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ip-based-login/reviews/)

 * 14 replies
 * 2 participants
 * Last reply from: [brijeshk89](https://wordpress.org/support/users/brijeshk89/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/logout-doesnt-always-work/#post-14153257)
 * Status: resolved