From 2ce53ede8e1a3e7797fc6d24343082a3fcced80e Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 9 Jul 2014 18:05:15 +0000 Subject: [PATCH] Persist the "Remember Me" state of the auth cookie when changing your own password. Props jesin. Fixes #27627. Built from https://develop.svn.wordpress.org/trunk@29043 git-svn-id: http://core.svn.wordpress.org/trunk@28831 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/user.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index 11972642ec..f134d5e6a2 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -1888,7 +1888,14 @@ function wp_update_user($userdata) { if ( $current_user->ID == $ID ) { if ( isset($plaintext_pass) ) { wp_clear_auth_cookie(); - wp_set_auth_cookie($ID); + + // Here we calculate the expiration length of the current auth cookie and compare it to the default expiration. + // If it's greater than this, then we know the user checked 'Remember Me' when they logged in. + $logged_in_cookie = wp_parse_auth_cookie( '', 'logged_in' ); + $default_cookie_life = apply_filters( 'auth_cookie_expiration', ( 2 * DAY_IN_SECONDS ), $ID, false ); + $remember = ( ( $logged_in_cookie['expiration'] - time() ) > $default_cookie_life ); + + wp_set_auth_cookie( $ID, $remember ); } }