This 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.
Important: Always back up your WordPress site (files and data) before modifying any files or performing any upgrades or installations!
If you don’t want to perform your own backups, then get help from a WordPress professional, or use a WordPress backup plugin.
How To Fix WordPress Keeps Logging Out Problem
(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 avoid 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)
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’).
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)
And …
(These settings are OK)
And …
(These settings are OK)
The settings below, however, are mismatched and will cause errors …
(These settings are not OK)
And …
(These settings are not OK)
And also …
(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, see this tutorial:
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 hosting company 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 …
(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)
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).
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)
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.)
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)
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)
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)
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’).
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.
To learn more about 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
See the tutorials in the section below if you experience any other issues or errors with WordPress:
(Source: Pixabay)
***
"I am beyond impressed with what you have put together. I can tell that you put a ton of hard work into building what you have. You have the absolute best content on WordPress I have ever seen!" - Robert T. Jillie
***