$rp_cookie
and $rp_path
are inside a function but are not initialized inside the function so they are out of scope and thus, empty. You can try calling global $rp_cookie, $rp_path;
at the start of your function but I don’t know if those variables have been set at the time your function is running and thus they might still be empty.
Another, more “modern” approach is to add the variable to the function scope by modifying the function signature as such:
add_action( 'validate_password_reset',
function rsm_redirect_after_rest($errors, $user) use ($rp_cookie, $rp_path) {
if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) {
reset_password( $user, $_POST['pass1'] );
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
wp_set_current_user( $user->ID );
wp_set_auth_cookie( $user->ID );
do_action( 'wp_login', $user->user_login );//`[Codex Ref.][1]
wp_redirect( home_url() );
exit;
}
}, 10, 2 )
Note the use ($rp_cookie, $rp_path)
following the anonymous function, but again, if those variable have not been set prior to running this function, they will still be empty. HTH.