• Good day.

    This is my first post here, I usually find everythingI am looking for the first time through but I am ready to admit defeat on this seemingly simple problem.

    All I want to do is set a cookie with one value that would be retrieved from teh URL. I want to use simple code like this:

    $src = $_GET[‘src’];
    setcookie(“source”, $src, time() + 864000, “/”, “.mysite.com”);

    Outside of wordpress using a simple php file, this function poses no problem. But as soon as I add this to my function.php template, the variable “$src” is no longer inserted into the setcookie function.

    If I do the following, the value for “src” prints fine on the screen:

    $src = $_GET[‘src’];
    setcookie(“source”, $src, time() + 864000, “/”, “.mysite.com”);
    echo $src;

    So, why why is it that the value for “src” will not insert into the setcookie function?

    Strangely enough, when I do something like this, it DOES insert the value for “src” without problem:

    $src = ‘100’;
    setcookie(“source”, $src, time() + 864000, “/”, “.mysite.com”);

    I know the answer must be simple, but I am absolutley stumped. Could this be a wordpress bug? Thanks a ton in advance for help in resolving this problem.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Creating a Simple Cookie?’ is closed to new replies.