2 clarify the question
source | link

Edit: The real issue is not whether a cookie is set while in that function but whether the test for the cookie passes on the redirected page. I've proved to myself elsewhere that a cookie is not relevant in this code but on a new page. The redirect appears not to satisfy this requirement.

Edit: The real issue is not whether a cookie is set while in that function but whether the test for the cookie passes on the redirected page. I've proved to myself elsewhere that a cookie is not relevant in this code but on a new page. The redirect appears not to satisfy this requirement.

1
source | link

Cookie is not set

A member sign-in form is processed in the theme's functions.php with the code below. For a test, when good credentials are entered in the form, the process is stopped with die("I LIKE COOKIE!");. So when that phrase appears in the browser it is expected that a rma_member cookie would be found in Chrome's settings. There is no cookie rma_member, just PHPSESSID, 4 wordpress..., and 2 wp... cookies. Varying arguments 2 - n in setcookie() has not (yet) made any difference. The setcookie() function returns true.

add_action('init', 'member_password_check');
...
    function member_password_check() {
        if (isset($_POST['_email'])) {
            $email = $_POST['_email'];
            if (empty($email)) {
                die('No email provided!');
            }
            $url = get_option('rma_base_url');
            $get_hash = get_option('rma_get_hash');
            $getURI = $url . $get_hash . '/' . $email;
            $data = wp_remote_get($getURI);
            $code = $data['response']['code'];
            if ('200' == $code) {
                //if good data returned
                $pwObject = json_decode($data['body']);
                $hash = $pwObject[0]->password;
                $password = $_POST['_password'];
                if (password_verify($password, $hash)) {
                    setcookie('rma_member', true, 3600, COOKIEPATH, COOKIE_DOMAIN);
                    die("I LIKE COOKIE!");
                    wp_redirect(home_url('member_content'));
                }
            } else {
                die('Username/password not found');
            }
        }
    }