How to Stay Logged in for Longer Periods in WordPress – Beginners Tip

Generally, whenever you log in to your WordPress site, it keeps you logged in for either 48 hours or until you close the web browser window and forces you to log in again. If you select the checkbox “Remember me” while logging in, WordPress gives you 14 days before forcing you to log in again.

That being said, if you are using a good, strong and long password then it would quite bothersome to remember it and reuse every couple of days or weeks. This is especially true if you are managing multiple WordPress sites, be it your own websites or the client sites.

So, if you ever want to, here is how you can easily stay logged in for longer periods of time in WordPress.

Stay Logged in for Longer Periods in WordPress

Configuring your WordPress site to stay logged in for longer periods is pretty easy.

1. To start off, log in to your site’s FTP account open the theme’s functions.php file.

2. Once the file has been opened, copy the below code and paste it in the file, save and reupload it. You can also paste the code in the site specific plugin.

// Stay logged in for longer periods
add_filter( 'auth_cookie_expiration', 'keep_me_logged_in' );
function keep_me_logged_in( $expirein ) {
    return 31556926; // 1 year in seconds

3. In case you are wondering, what the above code does is that it modifies the cookie expiration from default to one year so that you don’t have to re-authenticate for one entire year.

4. If you want to, you can modify the cookie expiration time by simply changing the time in seconds in line 4.

That’s all there is to do and from this point forward you can stay logged in for longer periods in WordPress.

Stay Logged in for Longer Periods Using Plugin

If you don’t want to mess with the files by adding the code snippets, then you can use the free plugin Configure Login Timeout.

1. To start off, install the plugin as usual and once installed, activate the plugin.


2. Now, open up the Login Timeout settings page by navigating to “Users” and then “Login Timeout.”


3. As you can see, the plugin settings are pretty straightforward. Just configure how long you want to stay logged in for both the general and “remember me” logins using the drop-down menu.

4. Now, click on the button “Save Changes” to save the changes.


That’s all there is to do and it is that simple to stay logged in for longer periods in WordPress.

Moreover, you may also want to know how to remove login shake effect when the password is wrong and tips to strengthen your WordPress site.

Hopefully that helps and do comment below sharing your thoughts and experiences about using the above methods to stay logged in for longer periods in WordPress.


  1. Hi,
    first of all thanks for share with all the community this code.
    I have two questions:
    I have introduced in my functions.php file your code.
    I have introduced the following value: 60
    I have introduced 60 (1 minuts…) for to test your code and to see how run.
    But after 1 minuts ( and after 1 hour…) I continue to stay with an open session.
    is it possible that wordpress do not accept time below the default time (48 hours)?
    If I use the code into functions.php, and I set the time for example in 30 years (higher than the date of 2038/01/19), in 32 bit system will be set automatically a timeout slightly before 2038/01/19? Or due to the date is higher than the date of 2018/01/19, so will remain the default time (48 hours)?
    Thanks for your support.
    I wish you a happy new year :)

    1. I’m using it and it works, with the difference that the add_filter is after the function itself. Don’t know if it makes a difference, but works for me. So:

      function keep_me_logged_in( $expirein ) {
      return 31556926; // 1 year in seconds
      add_filter( ‘auth_cookie_expiration’, ‘keep_me_logged_in’ );

      Also it only works for new sessions, if you had a previous session open it would still default to 48 hours. Quick fix would be to force all users to log out with a plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.