Few things can be more frustrating to a WordPress site user than to be logged out with no warning. It ruins productivity and raises stress levels, especially if it's a frequent problem. "WordPress session expired" are three words that no one wants to see.
Cookies authenticate every login session. Cookies are small amounts of data used to identify different computers and users to a computer network.
For example, cookies are created to remember you and your preferences on a website. This way you don't have to explain to that website what settings you want each and every time you visit.
Cookies are mostly to blame for the dreaded "WordPress session expired" error message. But there are some other possibilities.
This guide will show you how to troubleshoot and correct problems with WordPress timeouts.
No matter what the problem is, to fix it requires understanding it. When WordPress keeps logging out, we need to know the underlying mechanics in order to correct the error.
The root of this error lies in the WordPress login process. WordPress puts an authentication cookie in your browser at the beginning of a login session. This cookie is designed to match the WordPress Address URL from your settings.
If they do not match, such as if you attempt to access a WordPress address URL that isn't in your WordPress settings, the session can't authenticate. Instead, you will be logged out and presented with the troublesome "WordPress session expired" alert.
There are several possibilities that cause cookie-related errors. This guide will present proven solutions. We suggest following this guide chronologically for the quickest and easiest fixes.
The simplest and first solution to attempt is based on your own browser. If the WordPress page has been previously cached, your browser could be trying to use an old cookie to authenticate the session.
If so, clear your browser's cache and this will resolve the problem.
Another browser-related cause of this error can be found in your browser settings. If your browser is blocked from accepting cookies, WordPress won't be able to use session cookies and will log you out repeatedly.
In either browser, log in to your WordPress site to test if the expired session error continues.
It's good practice to make regular backups of your website.
Occasionally a plugin may have changed the code of your WordPress architecture itself. This change could be what is now causing WordPress to keep logging out.
Restore your website from one of your previous backups. it will revert the code to a time before the change. This will correct errors related to codes changed by plugins.
WordPress sessions are programmed to timeout after 48 hours. This timeout won't be the cause of frequent "WordPress Session Expired" errors, but changing it can reduce unneeded logins.
To extend the duration of a WordPress session you must create a child theme and modify the functions.php file. This is an advanced procedure to do correctly. Many things can go wrong and if you have multiple users it can create security concerns.
After creating the child theme, you will need to modify your functions.php file to extend the WordPress session duration
add_filter(‘auth_cookie_expiration’, ‘keep_me_logged_in_for_1_week’ ); function keep_me_logged_in_for_1_week( $expirein ) { return WEEK_IN_SECONDS; // 1 week in seconds}
This code will extend your WordPress login duration to one week, but it can be made even longer. Replace the word "week" in the code with either "month" or "year" to extend it even further.
There are two fields inside your WordPress Settings that are key to allow authentication cookies to function. These are the Site Address and WordPress Address fields. Both should have either a www or non-www URL.
To edit these, log in to your WordPress dashboard. Then go to Settings > General.
If you can't edit them from there it means you don't have admin access. They can also be updated by editing the wp-config.php file.
For non-www URLs use: define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com'); For www URLs use: define('WP_HOME','http://www.example.com'); define('WP_SITEURL','http://www.example.com');
Replace example.com with your site address.
Once both URLs are using identical addresses any issues caused by their conflicting URLs will be resolved.
If WordPress still keeps logging out repeatedly then the issue may be related to your plugins.
Plugins may also need to authenticate sessions with a cookie, but improper setup or plugin cookie issues could cause WordPress session timeouts.
Troubleshoot this by disabling your plugins one at a time. If the problem goes away while a particular plugin is disabled then that plugin is the cause of the error.
If the feature that the plugin provided is critically needed, search for an alternative. If there are none, report the issue to the plugin's creator and ask for a fix.
Few things are as stressful as when WordPress keeps logging you out. This guide has shown you why the "WordPress session expired" error happens and how to fix it.
Use these seven solutions to successfully resolve the 'session has expired' error.
The proven solutions from this guide will make sure you can fix any WordPress session expired error. You’re one step closer to mastering all things WordPress.
If you enjoyed reading this article on WordPress session expired, you should check out this one about WordPress updating failed error .
We also wrote about a few related subjects like failed to load resource error , WordPress posting to Facebook done automatically , how to reorder pages in WordPress and WordPress failed to import media .