1

I'm seeing an odd issue with my wp site. The problem is that it works fine locally but some people report seeing it at their side.

They report that after a login the navigation bar shows that they are still logged out. This problem gets solved once I ask them to refresh the page.

I'm stumped by this problem. I tried comparing the browsers and OSes and cannot see any pattern as such. One user reported seeing the issue on Chrome, FF as well as edge.

I use Google reCAPTCHA on my login page but I'm quite certain that that isn't causing it.

So I tried enabling a "login redirect" setting in which the user is redirected to the home page after they login. That doesn't solve the issue either.

Is anyone familiar with this issue? How can I have users logging into my WordPress site without making them refresh the page?

  • This sounds like a caching issue. Disable caching plugins and check with your host to see if they have caching enabled. – WebElaine Mar 31 '20 at 19:30
  • What is the value of the Cache-Control response from the server. You can check it by right clicking the page, select "Inspect" then click "Network" at the top and refresh the page. – Admiral Noisy Bottom Apr 1 '20 at 8:17
0

I finally solved this issue. I'm going to post my answer here so that it can help anyone else who's stuck with it. I spent an entire day trying to get it rectified.

Things that I tried on a staging site to troubleshoot this issue:

  1. Disable all plugins
  2. Change the theme
  3. Fiddling around various settings on the wordpress site

The problem was that if you open page X, Y before you login then after logging in when you visit X & Y it'll show that you're logged out. But other pages would show that you're still logged in. This observation was critical in reproducing the issue and determining that it's related to the cache.

Root cause:

I had some rules present in the .htaccess file that were setting the header to cache resources. This was causing a cache issue with the login.

I didn't add those rules. They were added automatically by SG Optimizer plugin which I installed when I was with the SiteGround host. After migrating hosts and removing the SG Opt. plugin, these lines were still present in the .htaccess file causing the issues.

Once I cleared the .htaccess file my site's login started working fine.

Next, I installed an actual caching plugin since the functionality had been disabled from the .htaccess file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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