fbpx
Blog

How to Fix the WordPress Keeps Logging Out Problem (6 Methods)

How to Fix the WordPress Keeps Logging Out Problem, featured image

If you’re trying to work on your website but WordPress keeps logging you out, you’ll likely start to feel pretty frustrated. Not only is it annoying to have to re-enter your credentials every few minutes, but it can also be time-consuming and interrupt your workflow.

This problem is often the result of an issue with the cookies WordPress uses to make sure you’re authorized to access the backend of your site. Fortunately, this means the solution is usually fairly simple.

In this tutorial, I’ll walk you through the go-to fixes for the WordPress keeps logging out problem (also known as WordPress session timeout error).

Let’s get right to it!

1. Clear Your Browsing Data

The first solution you can try is clearing your browser’s cookies and cache. Your site may be trying to use an expired cookie to verify your login credentials.

This process can vary a bit depending on which browser you’re using. I’ll demonstrate with Chrome since it’s the most popular option. First, access your browser settings by clicking on the three-dot icon in the top-right corner of the window:

The Chrome settings button.

You can navigate to Privacy and security > Clear browsing data from the primary settings screen, or for a shortcut, select More Tools > Clear browsing data from the settings menu:

The Clear Browsing Data option in the Chrome settings menu.

In the resulting window, make sure Cookies and other site data and Cached images and files are both checked. Then, click on Clear data:

Clearing the Chrome cache and cookies.

Check your WordPress site to see if it worked. If you’re still being logged out repeatedly, you can try the next solution.

2. Clear Your Site Cache

If you’re using a caching plugin to help speed up your site, you may also need to clear your site’s cache. You can usually find this option in your caching plugin’s settings:

Clearing the site cache with W3 Total Cache.

Your plugin may also prompt you to clear the cache if you’ve recently run an update.

It’s also possible that your browser is configured so that it doesn’t allow cookies for your WordPress site. Checking this issue will vary a little bit depending on which browser you’re using. Here, I’ll show you how to find the proper settings in Chrome.

First, head to your Privacy and security settings:

Chrome's privacy and security settings.

Click on Site Settings, and then look for the Cookie and site data section:

Chrome's cookies and site data settings.

If it says “blocked” under Cookie and site data, this is probably what’s causing the WordPress keeps logging out problem. Click on this section, and then select Allow all cookies from the options on the next screen:

Allowing all site cookies in Chrome.

After that, you can try accessing your site again.

4. Verify that Your WordPress Address and Site Address Match

If none of the fixes above have worked, it might be that the URL address on your WordPress site’s cookies doesn’t match your Site Address. To check this, navigate to Settings > General in your WordPress dashboard:

Accessing WordPress' general settings.

Look for the WordPress Address and Site Address settings and make sure they match. That includes ensuring that they both use the same protocol — either HTTP or HTTPS:

Checking the WordPress Address and Site Address.

Make any necessary changes and save your settings. If you’re having trouble completing this task because WordPress keeps logging you out, you can specify your WordPress Address and Site Address in your wp-config.php file instead.

To access it, you’ll need a File Transfer Protocol (FTP) client such as FileZilla and your FTP credentials which are provided by your host. Enter them into your FTP client to connect to your server, and then look for wp-config.php in the public_html directory:

Accessing wp-config.php via FileZilla.

Open it for editing, then add the following code before the line that reads That’s all, stop editing! Happy publishing:

define('WP_HOME','http://yoursite.com);
define('WP_SITEURL','http://yoursite.com);

Just make sure to replace the URLs with your own site’s address. Save the file, and then you can try logging in to WordPress again.

5. Troubleshoot for a Plugin Error

If none of the above solutions have worked, the next step is to determine if a plugin is causing WordPress to log you out repeatedly. This may be the case if you have a plugin installed that uses cookies and is experiencing an issue with them.

To test your plugins, I recommend that you create a staging site that allows you to perform this action safely, outside of your live site.

First, deactivate all of your site’s plugins using the Bulk actions feature on the Plugins screen:

Bulk deactivating plugins in WordPress.

Navigate around your site as you normally would to see if WordPress logs you out again or if the issue seems to be resolved. If you’re able to stay logged in, you can re-activate your plugins one at a time to see which of them causes the problem to re-occur.

Once you’ve pinpointed which plugin is causing WordPress to keep logging you out, you can delete it and replace it with a similar tool or troubleshoot the problem further (likely with help from the developer or the resources they’ve provided).

If you cannot access your WordPress dashboard long enough to deactivate all of your plugins, you can do so via FTP instead. Connect your client to your server, and then navigate to public_html > wp-content > plugins:

Accessing the plugins directory in FileZilla.

Here, rename each of your plugin folders to deactivate them (e.g. plugin-name-deactivated). Changing the names back will re-activate the plugins.

6. Change How Long WordPress Should Remember Users

Finally, you can change the length of time WordPress should remember users who have checked the Remember Me box on the login screen:

The Remember Me option on the WordPress Login screen.

This won’t necessarily fix the problem that is causing WordPress to keep logging you out. However, it should enable you to access your dashboard for longer stretches of time, which may be useful while further troubleshooting the underlying source of the problem.

To accomplish this, add the following code to your theme’s (or, preferably, your child theme’s) functions.php file:

add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );

function keep_me_logged_in_for_1_year( $expirein ) {
    return YEAR_IN_SECONDS; // 1 year in seconds
}

You can use the DAY_IN_SECONDS, WEEK_IN_SECONDS, or MONTH_IN_SECONDS time constants instead of YEAR_IN_SECONDS if you prefer WordPress to remember users for a shorter period of time.

Keep in mind that enabling users to stay logged in for extended periods of time could become a security risk, such as if someone were to access the computer of a user who has left their account logged in. Therefore, you’ll need to weigh the pros and cons of the duration you’ve chosen carefully.

Conclusion

It can be annoying to try and work on your site when WordPress keeps logging you out. Fortunately, there are several quick fixes you can try to get back to your uninterrupted workflow.

In this tutorial, we reviewed several potential solutions for this problem. You can start by clearing your browsing data and your site’s cache as well as checking your browser’s cookie settings. If that doesn’t work, check your WordPress and Site Addresses, troubleshoot for a plugin error, or extend the allowed session duration.

Do you have any questions about what to do if WordPress keeps logging you out? Leave them for us in the comments section below!

Share This Article:
Facebook Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *

Searching for a free, professional and lightweight WordPress theme? Meet Sydney!
View Theme
NEW FREE WOOCOMMERCE THEME! INTRODUCING BOTIGA
Win a Free 1TB CDN Account from KeyCDN Free Entry