Forums

set cookies in template ? (2 posts)

  1. desaintflorent
    Member
    Posted 6 months ago #

    I spend last 4 hours to try to set cookies in wordpress and look around for any solution... but i didn't find anything.

    Cookies are enabled in my browser ( firefox 3 ) and in the admin section wordpress cookies are set perfectly.
    But if i want to set my own cookies in the header of my template it's not working.

    I tried this :
    setcookie ("test", "actif", time()+3600);
    And this :
    setcookie ("test", "actif", time()+3600, "/", "localhost" );

    no results at all... it look like we can't set cookies in a template.
    I didn't find anything about that in google so i think i'm doing something wrong.

  2. desaintflorent
    Member
    Posted 6 months ago #

    Ok i just found the solution... I put that here for other with the same problem.

    I'm almost sure now, you can't set cookies in the header or footer or any template part.
    You can only set cookies in a plugin or in the function.php of your template.

Reply

You must log in to post.

About this Topic