I need to setup a cookie, however Chrome lately seems to accept them only through HTTPS. The "setcookie" function I use works everywhere except Chrome. If I move to HTTPS, it results as properly set up.
I tried to understand how WordPress works then, checking https://developer.wordpress.org/reference/functions/wp_set_auth_cookie/ and copied a bit of its parameters.
the final code is
$secure = (is_ssl() && 'https' === parse_url(get_option('home'), PHP_URL_SCHEME));
setcookie($name, $value, $expiration, COOKIEPATH, COOKIE_DOMAIN, $secure, true);
This is still not working though, what am I missing?