If you encounter a problem with WordPress logging out constantly, you may first try these steps: Deactivate plugins, empty the cache, clear the browser cookies.
Why does WordPress keep logging out?
WordPress sets a cookie in the browser to authenticate the login session. This cookie is set for the WordPress URL defined in the settings section of the admin area. If you are accessing from a URL different than the one in the WordPress settings, then WordPress will not be able to authenticate your session.
In the example above, the WordPress URL and the Site URL are different (one has www and the other doesn’t). URLs with www and without it are technically two different domains.
How to fix the login Issue
First make sure that you have the same URL in your Site Address and WordPress Address fields in the WordPress settings.
Login to the WordPress dashboard and go to Settings » General.
If for some reason you can’t access the admin area, then you can edit the wp-config.php file.
Using an FTP client, locate the wp-config.php file in the root directory. Download the file and open it in a text editor. Add this code above the line That’s all, stop editing! Happy blogging.
Or if your website doesn’t have a www.