int $length, int $user_id, bool $remember )
Filters the duration of the authentication cookie expiration period.
Duration of the expiration period in seconds.
Whether to remember the user login. Default false.
View all references
$expiration = time() + apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember );
An example of how to extend time in your WordPress session by a year, simply enter this code into your `functions.php` or plugin. Other durations have been added to show different times hat can be set.
It’s best to consider the $remember parameter and assign a shorter expiry when $remember is false (or leave it default). WP uses the difference between cookie expiry with and without “Remember me” as a heuristic flag in
wp_update_user(). After a password change, it guesses the user wants “Remember me” if the current cookie time left is longer than what this filter returns with $remember = false. Comment based on WP 5.0.2. — By kitchin —
Extension of the example, only extending expiration if $remember and low privelege.