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.
Why Extend Login Sessions?
Section titled “Why Extend Login Sessions?”- Reduce the need for frequent logins.
- Improve user experience for administrators and contributors.
- Useful for sites where users need long‑term access without interruptions.
Steps to Extend Login Sessions
Section titled “Steps to Extend Login Sessions”Method 1: Edit functions.php
Section titled “Method 1: Edit functions.php”-
Log in to WordPress with an administrator account.
-
In the dashboard, go to Appearance → Theme Editor.
-
Select your active theme and open the functions.php file.
-
Add the following code snippet:
// Extend WordPress login session to 1 yearadd_filter( 'auth_cookie_expiration', 'ruachost_extend_login_session' );function ruachost_extend_login_session( $expire ) {return 31556926; // seconds for 1 year} -
Save the file.
-
Log out and back in → Your login session will now last up to 1 year.
Method 2: Use a Plugin
Section titled “Method 2: Use a Plugin”If you prefer not to edit code, you can use plugins like Remember Me Control or Persistent Login to manage session duration.
Steps:
- Go to Plugins → Add New.
- Search for Persistent Login.
- Install and activate the plugin.
- Configure session duration under plugin settings.
Important Notes
Section titled “Important Notes”- 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.