Have you ever encountered the frustrating problem where WordPress keeps logging you out? Recently one of our users encountered this issue. She followed all the normal troubleshooting tips like deactivating plugins, emptying cache, clearing browser cookies, and even restoring WordPress from backups. None of the above worked for her. If you’re facing this issue, then we have a solution for you. In this article, we will show you how to fix WordPress keeps logging out problem also known as WordPress session timeout issue.
Why WordPress Keeps Logging Out?
In order to understand why WordPress keeps logging you out, you need to understand how the WordPress login process work.
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.
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).
If you don’t like the video or need more instructions, then continue reading.
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.
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.
If you prefer to use www in URL, then use this code instead
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.