Learn How to Fix WordPress Keeps Logging Out Issue

If you have ever come across this frustrating issue where your wordpress.org site keeps logging you out and you follow all the normal wordpress troubleshooting procedure like deactivating plugins, emptying cache, clearing browser cookies, and even restoring WordPress from backups and none of them worked for you, then this a solution for you.
What you will learn in this article will show you how to fix the issue of wordpress keeps logging you out from your admin area.This issue is also known as WordPress session timeout issue.
Why WordPress Keeps Logging Out?
First we must understand how WordPress login process work in order to understand why WordPress keeps logging you out. WordPress sets a cookie in your browser to authenticate a login session. This cookie is set for the WordPress URL stored in your settings section. If you are accessing from a URL that does not match the one in your WordPress settings, then WordPress will not be able to authenticate your session.
Incorrect WordPress URL Settings
As you can see in the settings screenshot above, the WordPress URL and the Site Address are two different URLs (notice one has www. and the other doesn’t).

Fixing The Login Issue

A simple fix for this login issue is to make sure that you have the same URL in your Site Address and WordPress Address fields in your WordPress settings. This means that you need to choose either www or a non-www URL in the both fields.
Login to your WordPress dashboard and go to Settings » General.
Correct WordPress URL Settings
If you can’t access the admin area, then you can update these fields by editing the wp-config.php file.
Connect to your website using an FTP client, and locate the wp-config.php file in your site’s root directory. You need to download this file to your Desktop and open it in a text editor like Notepad. Add this code just above the line That’s all, stop editing! Happy blogging.
1define('WP_HOME','http://example.com');
2define('WP_SITEURL','http://example.com');
If you prefer to use www in URL, then use this code instead
1define('WP_HOME','http://www.example.com');
2define('WP_SITEURL','http://www.example.com');
Don’t forget to replace example.com with your own domain name.

Why does this solution work?

Technically speaking, www is a subdomain itself. This means that URLs with www and without it are actually two different domains.
By changing and updating the URLs to the same address, it will fix the issue.
A more detailed technical explanation of www vs naked domain is here.
Also it’s important to note that incorrect settings in WordPress Address and Site Address fields may also result into too many redirect issue in WordPress.
We hope this article helped you fix WordPress session timeout issue. If it doesn’t then checkout how to fix WordPress login page refreshing and redirecting issue.

Comments