I want to set cookie in wprdpress but its not working.This is my code
add_action(\'init\', \'set_new_cookie\');
function set_new_cookie() {
setcookie
setcookie('cart_item',$carts,time() + (86400*30),'/');
Its working fine for me. / at the last is to set cookie for whole site. Remove / to set cookie for particulat directory only.
Well if this is the sequence your code runs then you need to switch the function and the call to it. Now you are calling the function before you initiated it.