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).
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.
define(‘WP_HOME’,’http://www.example.com’);
define(‘WP_SITEURL’,’http://www.example.com’);
If you prefer to use www in URL, then use this code instead
define(‘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.
If you liked this article, then please subscribe to ourΒ YouTube ChannelΒ for WordPress video tutorials. You can also find us onΒ TwitterΒ andΒ Google+.