I want to store a value if the visitor is on that page. I tried many code but the only way to create a cookie is to create a function an hook to init in the functions.php file. On this way I can not store variable values.

Is there a solution for this issue?

this is the code what works only on the functions.php

function cookietime() {
    setcookie('wp_time', 'testcookie');
add_action('init', 'cookietime');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.