Filters the duration of the authentication cookie expiration period.
Parameters
$length
int- Duration of the expiration period in seconds.
$user_id
int- User ID.
$remember
bool- Whether to remember the user login. Default false.
Source
$expiration = time() + apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember );
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
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.
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.Extension of the example, only extending expiration if $remember and low privelege.