Ecommerce Shopify WordPress Discussion

WordPress, setcookie and page conditionals

i have a specific request. Want to setcookie but only if user visit certain page. Regular conditionals are not working probably have something to do how wordpress loads. I tried with several hooks init, wp , template_redirect and noone of those works. If i am logged in then it works (its not a cache issue). function set_cookie_on_gift_page() { $is_gift_page = is_page('gift'); var_dump($is_gift_page); // Output the result of is_page for debugging purposes if ($is_gift_page) { setcookie('viewed_single_product_after_gift', 'true', time() + 3600, '/'); // Set cookie for 1 hour }} Also i tried regular is_page and other conditionals its always the same. However if u pust some echo 'test" those functions are working, but setcookie no.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.