Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Keep WordPress From Forgetting You With Remember Me

Nothing’s more frustrating than getting logged out of your WordPress dashboard right in the middle of editing a post or updating a plugin. We’ve had to deal with this while working on our own websites – deep into customizing the site or managing content, only to click somewhere and find ourselves staring at the login screen again.

By default, the “Remember Me” feature only keeps you logged in for two weeks. That might sound fine, until you realize how often you check your site.

For busy site owners, getting kicked out every two weeks is a real productivity killer.

The good news is that we’ve found an easy fix for this. With a tool called WPCode, you can extend your WordPress login sessions.

In this guide, we’ll show you how to use WPCode’s built-in snippet library to keep WordPress from forgetting you with Remember Me. You can easily set your login time from 2 weeks to 30 days, no coding needed. 🙌

How to Keep WordPress From Forgetting You With Always Remember Me

What Is the Remember Me Functionality in WordPress?

In WordPress, the ‘Remember Me’ login feature lets users stay logged into the content management system (CMS) for around 2 weeks.

So, if a user closes WordPress and has this feature turned on, they will automatically be signed in the next time they open WordPress within those 2 weeks.

Here’s what the ‘Remember Me’ checkbox looks like on the WordPress login page:

The WordPress login page

If WordPress users forget their login credentials, then they won’t need to worry about resetting their passwords, as they’ll be automatically signed in. Then, they can start working on their WordPress websites right away.

That said, 2 weeks may not be enough for people who frequently work on their websites, like bloggers or WooCommerce store owners. That’s why many users look for solutions to stay logged in for much longer.

In this article, we will share how to prevent your WordPress website from forgetting your user login by enabling the ‘Always Remember Me’ functionality. Here’s a quick overview of all the things we’ll cover in this guide:

Ready? Let’s jump right in!

This custom code method offers a straightforward way to stay logged into your WordPress website.

If you are new to adding code in WordPress, then the process may seem intimidating.

Many WordPress bloggers will suggest that you modify your code file, called functions.php, via your WordPress hosting provider’s file manager or an FTP client.

But in this step-by-step guide, we will use the WPCode plugin instead. It’s the best WordPress code snippets plugin and provides a much easier approach without the risk of breaking your website.

WPCode's homepage

Some of our business websites use WPCode to add and manage their custom code snippets. It’s been working exceptionally well, that’s why we highly recommend it. Check out our detailed WPCode review for insights into the plugin.

📝 Note: This guide will use the free version of WPCode. That said, if you are looking for more advanced features like a testing mode and conditional logic, then you can upgrade to the WPCode Pro version.

First, let’s install and activate the WPCode plugin. If you need some help, go ahead and check out our guide on how to install a WordPress plugin.

After that, you’ll want to head to Code Snippets » Library from the WordPress admin dashboard.

From there, you can search for the ‘Extend Login Expiration Time’ snippet. Once you find the snippet, hover over it and click the ‘Use snippet’ button.

Use the Extend Login Expiration Time snippet from the library

On the next page, you’ll see that WPCode has automatically added the code.

This code will extend the ‘Remember Me’ functionality to 30 days rather than 2 weeks.

WPCode automatically adds the code

It also has set the proper insertion method and added a title and tags to help you remember what the code is for.

Now, you can toggle the ‘Active’ button at the top menu to make the code work right away, and then click the ‘Update’ button.

Switch the toggle to 'Active' and click the 'Update' button

And that’s all you need to do to extend the ‘Remember Me’ feature for your WordPress user login screen.

🧑‍💻 Expert Tip: If you’re an advanced user, you can copy and paste this code into your functions.php file instead of using WPCode:

function wpbeginner_remember_me($expires) {
 
return 2419200; // Set the time in seconds (e.g., 2419200 for 4 weeks)
 
}
 
add_filter('auth_cookie_expiration', 'wpbeginner_remember_me');

You can make the duration longer than 4 weeks, but make sure to set the time in seconds.

You can also add the following code right below the code above to make the ‘Remember Me’ checkbox ticked by default:

function wpbeginner_login_checkbox() {
 
?>
 
<script>
 
document.getElementById('rememberme').checked = true;
 
document.getElementById('user_login').focus();
 
</script>
 
<?php
 
}
 
add_filter('login_footer', 'wpbeginner_login_checkbox');

Bonus Tip: What to Keep in Mind When Extending the WordPress Remember Me Feature

At WPBeginner, we understand how frustrating it is to be unexpectedly logged out of WordPress, especially when you are in the middle of something important. But there’s a good reason WordPress usually keeps you logged in for only 14 days.

It’s all about protecting your site from cybercriminals. These folks often try to break into your WordPress through password guessing or brute-force attacks.

If they manage to get hold of your computer or gain remote access, then they could easily hack into your WordPress site. In turn, they could cause real trouble for your website’s security. In other words, the 14-day limit is like an extra layer of defense against these potential risks.

In fact, some people remove the ‘Remember Me’ functionality entirely for security reasons.

The good news is that you can still prolong the ‘Remember Me’ feature without compromising your website security. Here are some tips:

  • Enable password protection on your WordPress login screen. Then, users must enter an additional username and password before they even reach the login page.
  • Limit the login attempts on your WordPress website. When hackers fail to access the admin page after a few attempts, WordPress will automatically lock them out.
  • Add two-factor authentication to WordPress. This feature will require new users to use an additional code on their login screen after entering their login credentials. If they don’t have the right code, then they won’t be signed in.

For more information about WordPress site protection, you can check out our ultimate WordPress security guide.

Expert Tip: Worried that you’ve been hacked? Our Hacked Site Repair Services are here to help! We offer fast turnarounds, a 30-day guarantee, and a complete backup of your cleaned website.

We hope this article has helped you learn how to keep WordPress from forgetting you by extending the ‘Remember Me’ feature. You may also want to bookmark our guides on:

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

6 CommentsLeave a Reply

  1. The WPCode plugin method you shared is perfect – way better than messing with functions.php directly. Here’s what I’ve learned from doing this myself: I always set different login times for different users. It works great! Admins get 30 days, while editors stay at the regular 14 days. It’s a nice balance of security and convenience.

  2. This plugin did not work for me. Anyone know why? I’m also having other issues with my site such as things changing by themselves. I don’t know if this is to do with the theme or wordpress or what..

  3. Thanks for this. I always checked the remember me button but it was always unchecked when I went back to the site. I wonder if this is due to my site not being live yet? Dunno.

  4. Hello, WP Beginner…

    Does this will fix my site because in my site if user click on remember me button. it doesn,t remember them even if they checked remember me.

    Also i using user ultra word press plugin. Does this compatible with that plugin

    Please reply…

  5. Again, you seem to know our pain points. This has really been bothering me lately. Thanks much.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.