How to set a cookie for logged in users to md5($user->ID . “my_secret”)?

Nevermind, I’ve figured it out: function init() { $user = wp_get_current_user(); if (!$user instanceof WP_User) return; $year = time() + 60 * 60 * 24 * 30 * 12; $auth = md5(join(‘_’, array($user->ID, “my secret”))); setcookie(‘visitor_id’, $user->ID, $year, “https://wordpress.stackexchange.com/”); setcookie(‘visitor_auth’, $auth, $year, “https://wordpress.stackexchange.com/”); } add_action(‘init’, ‘init’);

How to set a Cookie-Free Domain with WordPress?

Your mistake is the WP_CONTENT_URL’s postfix. You should set the definitions in the following manner: define(“COOKIE_DOMAIN”, “www.artisanplombier-pascher.com”); define(“WP_CONTENT_URL”, “https://static.artisanplombier-pascher.com”); Then, you should configure the static. subdomain’s path in your server’s configuration file or your hosting’s control panel. Create a subdomain named “static” or something similar and configure its path to your (WordPress) website’s “wp-content” folder. … Read more

Accept or deny cookies – how to?

If your question is regarding the new EU cookie policy, you only have to worry about third party tracking cookies that track between sites, WordPress cookies don’t fall within that category.

Issues with set cookie

If you’re doing this via a theme, add this line to your functions.php file: function set_user_cookie() { $school = “Some Value”; setcookie(‘default_school’, $school, time()+3600); } add_action( ‘init’, ‘set_user_cookie’); To display information add this line echo $_COOKIE[‘default_school’];

add_action in a custom plugin

It errors because class method is not a function. It’s not uniquely identified by its name alone. You need to provide instance of the object (or name of the class for static methods). In your context it would be: add_action( ‘init’, [ $this, ‘newsletterSuscriber’ ] );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)