How to keep users logged-in in WordPress

Keeping users logged-in is extremely important, so they don’t have to login everytime they open their app.

In some cases the user login time might be affected by your server configuration or even third-party plugins installed on your website.

Below you can see a function that will help with adjusting the login duration in WordPress, the code must be placed in your theme’s functions.php file:

// keep users logged in for longer in wordpress
function keep_users_logged_in_longer( $expirein ) {
    // 1 month in seconds
    return 2628000;
}
add_filter( 'auth_cookie_expiration', 'keep_users_logged_in_longer' );

Related Articles