I'm with a problem while setting cookies in this native Woocommerce function:

    public static function set_reset_password_cookie( $value = '' ) {
    $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
    $rp_path   = isset( $_SERVER['REQUEST_URI'] ) ? current( explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) : ''; // WPCS: input var ok, sanitization ok.
    if ( $value ) {
        setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
    } else {
        setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );

I don't know why it's not working, and if I put wp_die(var_dump(headers_sent()));, prints "bool(false)", so headers not already sent. I tried also add my own cookie in various locations in this function and don't work, but if add in functions.php, works like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.