Thread Starter
J B
(@kreuzian)
Not sure what to do. Correct me if I’m wrong.
if (!get_cookie(‘new_visitor’)) { —INSERTING code here would work BEFORE cookie planted??—-
// cookie not set, first visit
// create cookie to avoid hitting this case again
$cookie = array(
‘name’ => ‘new_visitor’,
‘value’ => ‘Yes’,
‘expire’ => time()+86500,
‘domain’ => ‘.my-domain.com’,
‘path’ => ‘/’,
‘prefix’ => ”,
);
set_cookie($cookie);
}
Thanks for the help.
Thread Starter
J B
(@kreuzian)
Basically if I put my code I only want to activate once, like my welcome message, in the spot mentioned above it would work only once, and then the cookie is planted right? and since it is activated only if it can NOT get_cookie then it wouldn’t activate again right?
just checking. thanks again.
Thread Starter
J B
(@kreuzian)
This is a code I wrote to test it to say “hello”, but it says:
Fatal error: Call to undefined function get_cookie()
<?php if (!get_cookie('new_visitor')) {?> hello <?php } ?>
// cookie not set, first visit
// create cookie to avoid hitting this case again
$cookie = array(
'name' => 'new_visitor',
'value' => 'Yes',
'expire' => time()+86500,
'domain' => 'mysite.com',
'path' => '/',
'prefix' => '',
);
set_cookie($cookie);
}
?>
How can I fix it?
Thread Starter
J B
(@kreuzian)
oops I saw one of my own errors in the code but the problem remains. are you suggesting I have to use codeigniter with wordpress? isn’t it a seperate platform?
How can I achieve this in wordpress without codeigniter. The cookiehelper doesn’t work.