How To Fix WordPress Keeps Logging Out Problem

Do you keep getting logged out of WordPress? Learn how to fix the WordPress keeps logging out problem in this tutorial …

How To Fix WordPress Keeps Logging Out ProblemThis tutorial is part of our FREE WordPress Management training and WordPress Troubleshooting tutorial series.

In this series of step-by-step tutorials, we show you how to troubleshoot and fix common WordPress errors.

Disclaimer

Important: Always do a backup of your WordPress site (files and database) before modifying any files or performing any upgrades or installations! 

If you don’t want to back up your site yourself, then consider using professional WordPress help services, or use backup plugins.

How To Fix WordPress Keeps Logging Out Problem

Do you keep getting logged out of WordPress?

(Do you keep getting logged out of WordPress?)

WordPress places a cookie on your web browser to authenticate your log in session for security purposes. If it can’t verify or authenticate your session, it will log you out.

Mismatched URLs

If there is a mismatch between the cookie set for your website URL stored in your web browser and the address specified in your WordPress site settings, the authentication will fail, resulting in an error that will log you out of your session.

To prevent this error, your WordPress Address (URL) and Site Address (URL) fields should use the same prefix in the hostname (i.e. if you use ‘www’ in your site’s address, then both fields should display the ‘www’ in the URL).

To check that mismatched settings are not the cause of the error, log into your admin area, then go to Settings > General Settings and make sure that both your WordPress Address (URL) and Site Address (URL) fields use the same URL prefix …

Mismatched URL prefixes can cause logouts

(Mismatched URL prefixes can cause logouts)

If your WordPress Address (URL) doesn’t match the domain prefix of your Site Address (URL), WordPress sees this as two different websites (e.g. one site with ‘www’ and another without the ‘www’).

Tip

Note: We are not referring here to having a different WordPress Address (URL) than a Site Address (URL) if your site requires these to be different in order to work. What we mean is both URLs either must use ‘www’ in the prefix or both should use the ‘non-www’ version.

So, the settings below are OK …

These settings are OK

(These settings are OK)

And …

These settings are OK

(These settings are OK)

And …

These settings are OK

(These settings are OK)

The settings below, however, are mismatched and will cause issues …

These settings are not OK

(These settings are not OK)

And …

These settings are not OK

(These settings are not OK)

And also …

These settings are not OK

(These settings are not OK)

If you need help configuring General WordPress settings or understanding what these settings mean, go here:

If You Cannot Log Into WordPress

If you cannot log into your WordPress admin area or access your Settings section, then your login details need to be manually overriden.

This involves logging into your server using FTP or cPanel’s File Manager and editing your wp-config.php file. If you need help with this, go here:

Disclaimer

The wp-config.php file is a very important WordPress file. If you don’t want to edit code in your WordPress installation files or don’t feel confident making changes on server files, then contact your web hosting provider or a professional WordPress technical support service provider for help.

How To Manually Override Your WordPress Login Details

Access your server using FTP or cPanel File Manager and locate your wp-config.php file …

locate your wp-config.php file

(wp-config.php file)

Right-click on the file and select ‘Download’ to save a copy to your hard drive …

Download wp-config.php to your hard drive

(Download wp-config.php to your hard drive)

Next, open up the wp-config.php file using a plain text editor (use your operating system’s built-in editor or an application like NoteTab).

Tip

If you can’t see the file in your text editor browser, make sure to select ‘All files (*.*)’ in the ‘Files of type:’ menu …

Open wp-config.php using a text editor

(Open wp-config.php using a text editor)

Scroll down all of the code until you find a line that says “That’s all, stop editing! Happy blogging.” …

That's all, stop editing! Happy blogging.

(That’s all, stop editing! Happy blogging.)

Above this line, you will need to enter the following two lines of code (replace yoursite.com with your domain and make sure than both lines use either ther ‘www’ or the ‘non-www’ version) …

Add these lines to your wp-config.php file

(Add these lines to your wp-config.php file)

After typing in the two lines shown above, your wp-config.php file should look like the screenshot below …

Your edited wp-config.php file

(Your edited wp-config.php file)

Save the file and upload the modified wp-config.php file to your server, overwriting the existing file on your server …

Upload your edited wp-config.php file to your server

(Upload your edited wp-config.php file to your server)

After uploading the edited wp-config.php file to your server, you should be able to log into your WordPress site. Hopefully, this will fix the problem and the WordPress cookie will recognize that you are logging in from the same website, instead of seeing two different sites (one with ‘www’ and the other with no ‘www’).

Useful Tip

Hardcoding your login values into the site itself is not the best way to fix this problem, it’s just a way to get you back into your site if you are unable to login. With this method, you won’t be able to edit your site’s URL settings on the General settings page.

For more information on this method, including what to do if you run into problems, see the official WordPress technical documentation below:

In addition to the above, check out this video on how to fix the WordPress keeps logging out problem from the team at MyThemeShop:

(How to fix the WordPress keeps logging out problem. Video: MyThemeShop)

More WordPress Troubleshooting Tutorials

If you experience additional issues with WordPress, please refer to the tutorials in the section below:

How To Fix WordPress Keeps Logging Out Problem

(Source: Pixabay)

***

"This is AMAZING! I had learnt about how to use WordPress previously, but this covers absolutely everything and more!! Incredible value! Thank you!" - Monique, Warrior Forum

Disclaimer: This site has no association with WordPress, Automattic, or any products mentioned on this website. We may derive affiliate commissions from purchases of any third-party products and services mentioned on our website. All images are the copyright of their respective owners, comply with all license terms and agreements of use are used solely for illustrative or training purposes.

***

Did you find this post useful? If so, please take a moment to use the social buttons below to share this page with anyone who can benefit from WordPress.

Author: Martin Aranovitch

Martin Aranovitch is the founder of WPCompendium.org and has authored hundreds of FREE WordPress tutorials for non-techies and beginners. WPCompendium.org provides detailed step-by-step tutorials that will teach you how to use WordPress with no coding skills required and grow your business online at minimal cost!