• Hello! I am using the latest version of wordpress, but for some odd reason, I can’t seem to read cookies off of my own domain.

    I created a blank template with only the following code:

    <?php
    /*
    Template Name: Test
    */
    
    setcookie('shabba', 'voted-'.$_SERVER['REMOTE_ADDR'], time() + (86400 * 14 * 30), '/');
    ?>
    
    <?php var_dump($_COOKIE); ?>

    I can immediately see the cookie get set via firebug or chrome or internet explorer. However, the when doing a var_dump, it shows the array being empty. (array(0) { } )

    When I log in and then pull up a page that has my blank template, it immediately shows all cookies, including the one that I set before logging in.

    Is there something in wordpress that clears the $_COOKIE superglobal? If so, how do I override this behavior?

    When searching the forums, there is a lot of information on setting cookies, but no one seems to report this issue.

    Thanks in advance for any tips.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$_COOKIE superglobal is empty unless I am logged in’ is closed to new replies.