Extend WordPress Login Expiration

The default login session cookie is 48 hours. Although it’s usually enough for most users, it can be frustratingly short for developers and administrators. Here’s something useful for those who do not want the hassle of logging in now and then. Add this to your theme’s functions.php , or create a php file and load it in the Must Use Plugins folder:

add_filter( 'auth_cookie_expiration', 'new_login_session_period' );
function new_login_session_period( $expirein ) {
    return 31556926; // this equals to 1 year in seconds
}

But I guess you’ll also have to make sure that your browser settings does not expire your cookies within 1 year (or any figure that you’ve specified) for the above to work.

Leave a Comment