How to Solve WordPress Session Expired Problem

Since you clicked on this article we can safely assume that you’ve seen the WordPress session expired error at least a few times in your life. And believe us when we say, we understand how frustrating it can be to get logged out of your Admin dashboard without a clue as to why exactly.

We've all experienced the #WordPress #session expired problem at least once in our life. To be ready for that situation in the future, check out all the possible methods of resolving it in this article! Click To Tweet

This error arises often when you are making or saving changes. And the reasons behind why the error happens and why you were logged out are plenty, meaning there is definitely more than one solution you can try to implement in order to resolve it.

In this article, we will be teaching you exactly that, or in other words, we will be demonstrating the best solutions for the session timeout error.

So without further ado, let’s get right into it!

What causes the issue in the first place?

One thing we always say when writing these types of articles is that in order to successfully solve an issue, you have to first get to the root of it. For that reason, before we dive into all the possible ways you can go about fixing this error, we are first going to quickly talk about what might be causing it in the first place.

Session expired error

Every time you log into WordPress a browser cookie is set which is intended for authenticating your session. If there are any errors with the cookie WordPress will see your session as unauthenticated and will automatically log you out while showing you the “session expired” notice.

When it comes to the errors related to the cookie, there are several are possibilities, and exactly for that reason, we will dedicate the rest of this article to listing all the proven methods of resolving those errors.

Most efficient error resolution methods

Clear your browser cache

Since cookies are closely related to browsers, the error could in fact stem from your browser. How? Well, the page might be cached in your browser along with an expired cookie, which will make the authentication fail repeatedly.

For that reason, one of the first things you should do when trying to resolve the session expired error is clearing your browser cache.

Clear your browser cookies

Very much connected to what we just said, the error could also be caused by an existing expired cookie that is overriding your recent login and kicking you out of your site.

So naturally, you should give your browser cookie collection a cleanup.

Make sure that you are permitting WordPress to save cookies

In some cases, it could happen that your browser isn’t accepting cookies simply because it has been disabled from doing so. What this means is that WordPress will have no way of saving cookies which will lead to you being logged out over and over again.

Luckily, enabling this option is pretty easy and can be done through the Settings tab in your Chrome browser (but in other browsers as well).

So, go into Settings, find the Privacy and Security section, and then click on the Cookies and other site data option.

Privacy and security section

On the page dedicated to Cookies and other site data, you can choose to allow all cookies by selecting the option shown in the screenshot below.Enable all cookies option

Or, you can allow cookies only from specific sites, in this case, your WordPress site.

You can do so by adding its domain to the list of Sites that can always use cookies which is located close to the bottom of the page.

Enter site domain input

Clear your WordPress site cache

Your browser cache isn’t the only suspect that might be causing this issue, your WordPress site cache could be to blame as well. Meaning in order to fix the issue you should also try clearing your site’s cache as well.

To make this happen, you will have to check with your host how exactly this should be done since the process will differ from host to host.

Another thing, double-check if you are using a caching plugin on your site and if yes, check the documentation of the plugin for potential answers.

Delete your plugins

A plugin might be trying to authenticate your session but because the plugin itself is not properly set up, the session never gets authenticated. In that situation, your best bet is to disable all your plugins.

Since we all know that manually disabling plugins can be quite tedious, we have found a one-click solution for completing the task, that solution being the WP Reset plugin.

WP Reset

This plugin is able to reset an entire site or just specific aspects of it to a clean slate or a previous version, in just a click.

Using this plugin you can easily reset your site’s plugins section. The whole process will be initiated with just one click and will take only a few seconds.

Delete plugins option

With the plugin comes something called the Emergency Recovery Script which can revive your site form the white screen of death and which will allow you to delete plugins (in bulk or one by one) even if you can’t access the WP Admin dashboard.

Best of all, WP Reset gives you the option to create collections of plugins (and themes) which you can install in bulk post reset or at any time that you want.

Plugin collections feature

Try restoring your website from a previous backup

Sometimes it’s possible that a plugin changed the code in your WordPress architecture and that is now causing the session expired error.

If you think this might be the reason why you are facing the issue, then you should try restoring your website from a previous backup which we hope you create regularly.

WP Reset can also help out in this situation. Although it’s not a backup plugin, it does have a snapshot feature that will take a snapshot of your database prior to you making any changes to your website.

Snapshots feature

Theses snapshots will enable you to take your site to a previous and hopefully error-free state in just a few clicks.

Extend the time you are remembered on the site

If it happens that someone changed the duration of the time that you are remembered by your WordPress site or you simply don’t think the duration is long enough, you can manually update it.

How? Well first create a child theme if you don’t already have one. Next, in the functions.php file belonging to the child theme, add the following filter.

add_filter( ‘auth_cookie_expiration’, ‘keep_me_logged_in_for_1_year’ );

function keep_me_logged_in_for_1_year( $expirein )

{ return YEAR_IN_SECONDS; // 1 year in seconds }

Attention! This filter will remember a user for one year, but if you want to be remembered for a shorter period of time, then use one of these filters instead: DAY_IN_SECONDS (remembered for only one day), WEEK_IN_SECONDS (remembered for only one week), MONTH_IN_SECONDS (remembered for only one month).

Check your WordPress site settings

If none of the above-mentioned solutions worked for you, then you can try this final method of resolving the WordPress session expired error.

As you already know, WordPress sets a cookie in the browser to authenticate the login session. That cookie is only set for the WordPress URL which is stored in your settings section.

Meaning, WordPress will not be able to authenticate your session if the URL you are accessing doesn’t match with the one in your WordPress settings.

As you can see in the screenshot below, there are two different URLs shown, the WordPress Address (URL) and the Site Address (URL).

Incorrect site settings

Notice how one includes “www” and the other one doesn’t?.

You need to make sure that you have the same URL in your WordPress Address field and Site Address field. How can you make this happen?

Login to the WordPress dashboard and go to Settings >> General. There, type in the correct URLs and click Save.

Correct site settings

Alternatively, you can update these fields by editing the wp-config.php file.

Connect to your website with the help of an FTP client and locate the wp-config.php file in the site’s root directory. Download the file and open it in any text editor.

Add the following code above the commented line “That’s all, stop editing! Happy Blogging”.

Define (‘wp_home’,’http://example.com’);
Define (‘wp_siteURL’,’http://example.com’);

Or, if you use www in your URL.

Define (‘wp_home’,’http://www.example.com’);
Define (‘wp_siteURL’,’http://example.com’);

Of course, replace “example.com” with the actual domain name you are using, and you are done!

Conclusion

All the methods we mentioned in this article could help you to resolve the WordPress session expired error. Which exact method will do the trick will of course depend on what caused the error in the first place.

We hope you enjoyed reading this article. And please if you do have any questions, let us know in the comments below!

Leave a Comment