WordPress login extension wordpress persistent login

Arun - 10/12/2020 6:43 PM

2 types of code are given.
1 for the users who have marked remember and another who have not. The remember me is tested and working but without ticking remember me is not checked.

original source- https://wpcrumbs.com/how-to-extend-authentication-cookie-expiration-time/

Files 2

functions.php
php
function bg_change_cookie_expiration($expiration, $user_id, $remember) {
    $expiration = 100 * DAY_IN_SECONDS; // means 100 days and the default value is 14 days
    return $expiration;
}
add_filter('auth_cookie_expiration', 'bg_change_cookie_expiration', 10, 3);
functions.php
php
function bg_change_cookie_expiration($expiration, $user_id, $remember) {
    if ($remember) {
        $expiration = 100 * DAY_IN_SECONDS; // means 100 days and the default value is 14 days
    }

    return $expiration;
}
add_filter('auth_cookie_expiration', 'bg_change_cookie_expiration', 10, 3);