Support » Fixing WordPress » Cookies Not Set – Proper Format Being Used in Functions.php

  • Hello,

    I’m using 3.6 & Woothemes Spectrum theme and have tried putting this in header.php and also functions.php (top) in the theme directory – still no luck on the cookie being set:

    function set_newuser_cookie() {
    	if (!isset($_COOKIE['sitename_newvisitor'])) {
    		setcookie('sitename_newvisitor', 1, time()+1209600, COOKIEPATH, COOKIE_DOMAIN, false);
    add_action( 'init', 'set_newuser_cookie');

    I am wondering if it could be something in my theme? Or if I should try putting it somewhere else. I need to be able to set cookies.

    Also, I realize it’s not going to happen on the first page load, but even after reloading the page I see it’s not set. Any ideas? Thank you.

  • The topic ‘Cookies Not Set – Proper Format Being Used in Functions.php’ is closed to new replies.