I’m having a WordPress website, and on main page, if visitor is here for the first time, a ‘Subscribe to newsletter’ modal appears. I’m having a problem that cookie is not being set via setcookie()
function:
<?php
if($_COOKIE['rcngVisited'] != 'true')
{
echo do_shortcode('[modal name="Subscribe to newsletter" style=button color=default size=default][/modal]');
setcookie('rcngVisited','true', time()+60*60*24*30, '/readyclickandgo/');
}
?>
You only set the cookie for
readyclickandgo
dirMake sure you don’t have any output before you set
COOKIE
, add this in your header:Add this anywhere you want in same page: