add_action( 'wp', 'setCookies', 10);
I am using this hook to set cookies. I am using 'wp' because I need to get the current post ID.
Now on my sidebar.php, I am calling
if(isset($_COOKIE['cookiename'])) but it returns nothing.
I checked on chrome devtools and
cookiename = postID is exisiting there.
When I refresh the page or go to another page, the cookie is now returning something.
So I'm guessing maybe my cookie is being set only after the sidebar.php is loaded? If so, is there a way around this?