Skip to content

Extending User Login Sessions on WordPress

By default, WordPress login sessions expire after a short period of inactivity. This means users may need to re‑enter their credentials frequently. On ruachost.com, you can extend login sessions by modifying WordPress settings or adding a custom function.

  • Reduce the need for frequent logins.
  • Improve user experience for administrators and contributors.
  • Useful for sites where users need long‑term access without interruptions.
  1. Log in to WordPress with an administrator account.

  2. In the dashboard, go to Appearance → Theme Editor.

  3. Select your active theme and open the functions.php file.

  4. Add the following code snippet:

    // Extend WordPress login session to 1 year
    add_filter( 'auth_cookie_expiration', 'ruachost_extend_login_session' );
    function ruachost_extend_login_session( $expire ) {
    return 31556926; // seconds for 1 year
    }
  5. Save the file.

  6. Log out and back in → Your login session will now last up to 1 year.

If you prefer not to edit code, you can use plugins like Remember Me Control or Persistent Login to manage session duration.

Steps:

  1. Go to Plugins → Add New.
  2. Search for Persistent Login.
  3. Install and activate the plugin.
  4. Configure session duration under plugin settings.
  • Always back up your theme before editing functions.php.
  • Use a child theme to preserve changes during updates.
  • Longer login sessions may reduce security only enable this for trusted users.