Skip to content

Fix auth cookie documentation and remove unnecessary filter in wp_set_auth_cookie() #8648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/wp-includes/pluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -970,9 +970,9 @@ function wp_parse_auth_cookie( $cookie = '', $scheme = '' ) {
/**
* Sets the authentication cookies based on user ID.
*
* The $remember parameter increases the time that the cookie will be kept. The
* default the cookie is kept without remembering is two days. When $remember is
* set, the cookies will be kept for 14 days or two weeks.
* The $remember parameter determines if the cookie will persist beyond the session.
* When $remember is true, the cookie is kept for 14 days (two weeks).
* When $remember is false, the cookie is a session cookie and expires when the browser is closed.
*
* @since 2.5.0
* @since 4.3.0 Added the `$token` parameter.
Expand All @@ -984,6 +984,9 @@ function wp_parse_auth_cookie( $cookie = '', $scheme = '' ) {
* @param string $token Optional. User's session token to use for this cookie.
*/
function wp_set_auth_cookie( $user_id, $remember = false, $secure = '', $token = '' ) {
$expire = 0;
$expiration = time() + ( 2 * DAY_IN_SECONDS );

if ( $remember ) {
/**
* Filters the duration of the authentication cookie expiration period.
Expand All @@ -1001,10 +1004,6 @@ function wp_set_auth_cookie( $user_id, $remember = false, $secure = '', $token =
* Needed for the login grace period in wp_validate_auth_cookie().
*/
$expire = $expiration + ( 12 * HOUR_IN_SECONDS );
} else {
/** This filter is documented in wp-includes/pluggable.php */
$expiration = time() + apply_filters( 'auth_cookie_expiration', 2 * DAY_IN_SECONDS, $user_id, $remember );
$expire = 0;
}

if ( '' === $secure ) {
Expand Down
Loading