sinanisler logo

Extending or Changing WordPress Login Session Duration

This WordPress code snippet extends the duration of the login session, keeping users logged in for a longer period. By default, WordPress logs users out after a certain period of inactivity for security reasons. However, for convenience, especially on less security-sensitive sites, you might want to extend this duration. This snippet sets the login expiration to 30 days, but you can adjust the duration as needed

add_filter( 'auth_cookie_expiration', 'snn_extend_login_expiration' );
function snn_extend_login_expiration( $duration ) {
    return 30 * DAY_IN_SECONDS; // 30 days in seconds. You can adjust the duration here.
}

Leave the first comment