How WordPress login ‘Remember Me’ works

When you select the ‘Remember Me’ option on the WordPress login page, a cookie is stored on your computer that contains information that allows you to automatically log in when you return to the site.

The cookie is stored in the browser’s local storage and its name and contents depend on the specific settings of the WordPress site you are using.

The cookie contains a randomly generated authentication token.

How long will it remember me?

By default, the “Remember Me” cookie expiration is set to 14 days.

Even if you close your browser or shutdown your computer – if you return to the website within this time you will be automatically logged in.

How do I change the expiration period?

To customize the remember time, you can use the auth_cookie_expiration hook.

If you’re not sure where to place this code I highly recommend you read How to create a WordPress plugin for your custom functions.

function custom_remember_me_expiration( $expiration ) {
    return 60 * 60 * 24 * 30; // 30 days
}
add_filter( 'auth_cookie_expiration', 'custom_remember_me_expiration' );

This code sets the expiration time to 30 days.

You can adjust the value to your desired length of time. Keep in mind that longer expiration times can increase the security risk of your site, so it’s important to carefully consider the expiration time you choose.