How To Fix WordPress Keeps Logging Out Problem

Do you keep getting logged out of WordPress? Learn how to fix the WordPress keeps logging out problem in this tutorial …

How To Fix WordPress Keeps Logging Out ProblemThis 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

Important: Always do a backup of your WordPress site (files and data) before modifying any files or performing any upgrades or installations! 

If you don’t want to back up your data manually, then get professional support, or use a backup plugin.

How To Fix WordPress Keeps Logging Out Problem

Do you keep getting logged out of WordPress?

(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 issue, 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

(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’).

Useful Tip

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

(These settings are OK)

And …

These settings are OK

(These settings are OK)

And …

These settings are OK

(These settings are OK)

The settings below, however, are mismatched and will cause errors …

These settings are not OK

(These settings are not OK)

And …

These settings are not OK

(These settings are not OK)

And also …

These settings are not OK

(These settings are not OK)

If you need help configuring General WordPress settings or understanding what these settings mean, refer to the tutorial below:

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, refer to the tutorial below:

Warning

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 web 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 …

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

(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).

Useful Tip

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

(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.

(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

(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

(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

(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 issue 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’).

Useful Tip

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

Check out the tutorials in the section below if you experience additional issues with WordPress:

How To Fix WordPress Keeps Logging Out Problem

(Source: Pixabay)

***

"Your training is the best in the world! It is simple, yet detailed, direct, understandable, memorable, and complete." Andrea Adams, FinancialJourney.org

***

Recommended Video Courses For WordPress Users

How To Use FTPHow To Use FTP

This video course shows you how to use FTP (File Transfer Protocol) to transfer and upload files between your hard drive and your server using a free FTP program called Filezilla.

More info: How To Use FTP

Recommended Video Courses For WordPress Users

How To Install, Set Up & Use WordPress MultisiteHow To Install, Set Up & Use WordPress Multisite

Learn how to quickly and securely set up an online community of websites or blogs using the powerful WordPress Multisite feature.

More info: WordPress Multisite

Recommended Video Courses For WordPress Users

How To Set Up A Forum On WordPressHow To Set Up A Forum On WordPress

Learn how to set up a forum for your visitors, prospects, customers, members, or affiliates using WordPress.

More info: How To Set Up A Forum On WordPress

Recommended Video Courses For WordPress Users

How To Use cPanelHow To Use cPanel

cPanel is a powerful and simple-to-use web hosting management software application that gives website owners the ability to quickly and easily manage their servers and websites using a simple and intuitive dashboard.

This video course will teach you how to use the main features of cPanel to manage your web hosting.

More info: How To Use cPanel

Recommended Video Courses For WordPress Users

How To Back Up & Restore WordPress SitesHow To Back Up & Restore WordPress Sites

Learn how to safely and automatically backup your WordPress files and database and how to easily restore your WordPress site if something were to happen.

More info: How To Back Up & Restore WordPress Sites

Recommended Video Courses For WordPress Users

Using Password ManagersUsing Password Managers

Password Managers provide an easy and secure way to keep track of all your passwords. This video course shows you how to use two FREE powerful password management tools.

More info: Using Password Managers

Recommended Video Courses For WordPress Users

How To Optimize WordPressHow To Optimize WordPress

Learn how to optimize your WordPress site and improve your page loading speed.

More info: How To Optimize WordPress

Recommended Video Courses For WordPress Users

How To Use Amazon S3How To Use Amazon S3

Learn how to set up and use Amazon S3 to upload, store, manage, and protect your site’s images, large media files, downloadable files, stream videos and more.

More info: How To Use Amazon S3

Recommended Video Courses For WordPress Users

How To Set Up WordPress On LocalhostHow To Set Up WordPress On Localhost

Learn how to install, set up, and locally host a fully functioning WordPress site on your computer.

More info: How To Set Up WordPress On Localhost

Recommended Video Courses For WordPress Users

WordPress SecurityWordPress Security

Learn how to keep your WordPress site or blog secure and protected from malware, hackers and brute-force attacks.

More info: WordPress Security

Author: Martin Aranovitch

Martin Aranovitch is the founder of WPCompendium.org and the author of The Small Business Digital Manager. WPCompendium.org provides hundreds of FREE tutorials that show you how to use WordPress to grow your business online with no coding skills required! Get our FREE "101+ WordPress Tips, Tricks & Hacks For Non-Techies" e-course with loads of useful WordPress tips!

Originally published as How To Fix WordPress Keeps Logging Out Problem.