apply_filters( 'auth_cookie_expiration', int $length , int $user_id , bool $remember )
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
File: wp-includes/pluggable.php
.
View all references
$expiration = time() + apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember );
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
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.
Top ↑
Feedback
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.