This is a recap for my problem - after a form is submitted it will save a token (a cookie token)
function set_cookie_token( $entry, $form ) {
setcookie('token', 'true', time() + (86400 * 30), "/");
}
add_action( 'form_after_submission', 'set_cookie_token', 10, 2 );
function open_dcookie() {
if (isset($_COOKIE['token']))
return $_COOKIE["token"];
}
add_action( 'wp', 'open_dcookie' );
the form works fine since after submission I can see the registration of token in my console.
the problem is my wordpress website will read the cookie if im logged in, but it will not if im not.
this is how i read the cookie
echo open_dcookie();
echo $_COOKIE['token'];
as mentioned, it will only output the cookie if im logged in, it was working on my localhost but when the site was moved to https, i have encountered this problem, so was it the https? is it something about a caching problem? or is my declaration of cookies for an https wrong???