Set a simple cookie in functions.php
-
I have tried everything but I know I’m missing something simple.
Trying to set a cookie when someone goes to a page. I am using the functions.php file for the theme for that specific page. I have multiple themes on my site.
Using code:
function set_new_cookie() {
setcookie(‘SESSIONKEY’, ‘W8FREEBTG’, 3600, ‘/’, ‘/les.com’);
}
add_action( ‘init’, ‘set_new_cookie’);Anyone see why my cookie is not being set. This code is at the bottom of the file. If I refresh the page shouldn’t the cookie show in the Cookie manager?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Set a simple cookie in functions.php’ is closed to new replies.