R
R
Roman Govorov2019-02-08 15:50:30
HTTP Cookies
Roman Govorov, 2019-02-08 15:50:30

How to set cookies in WordPress CRM?

How to set a cookie not through the function.php file but anywhere else in WordPress?
I have attached php file which works but doesn't set cookies, I did like this, it doesn't work like this:

$x = 'установлены!';
setcookie("Cookie", $x);

Works through function.php like this:
function set_new_cookie() {
    if (!isset($_COOKIE['Cookie'])) {
        $x = 'установлены!';
        setcookie("Cookie", $x);
    }
}
add_action( 'init', 'set_new_cookie');

But I need not through function....

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question