Store value in cookie

Use setcookie() like shown below: setcookie( $name, $value, time() + 3600, COOKIEPATH, COOKIE_DOMAIN ); Note: $wpdb->insert_id AFAIK will always return false or 1, so I’m not sure if that will be of value for your. I might be wrong about that see @s_ha_dum’s comment.

Referrer URL with jQuery or Javascript – Cache & Referrer URL Issue

I don’t have the answer build on cookie, but I think this isn’t sensitive data, you can try localStorage. jQuery(document).ready(function($){ var initreferrer = document.referrer; if(initreferrer.indexOf(‘yourdomain.com’) === -1 ) { // Check if the referer is your site or not. If not( return -1 ) set the localStorage. localStorage.setItem(“mysite_referrer”, initreferrer); } }); Then you can use … Read more

Setting cookies in WP REST API requests

Adding this line to my $.ajax call fixed the problem for me. $.ajax({ xhrFields: { withCredentials: true }, // the rest… Sidenote: this requires the following header to be set on the server-side, which is enabled by default with the REST API (it seems). Access-Control-Allow-Credentials:true

Passing cookies when using wp_remote_get

The arguments array for wp_remote_get accepts a cookies parameter: $cookies = []; $cookie = new WP_Http_Cookie( ‘cookie_name’ ); $cookie->name=”cookie_name”; $cookie->value=”your cookie value”; $cookie->expires = 7 * DAY_IN_SECONDS; // expires in 7 days $cookie->path=”https://wordpress.stackexchange.com/”; $cookie->domain = ‘.reddit.com’; $cookies[] = $cookie; $url=”https://tumblr.com/some/url/”; $args = [ ‘cookies’ => $cookies, ]; $response = wp_remote_get( $url, $args );

How to generate the COOKIEHASH from JavaScript

By default it’s the MD5 hash of the site URL: $siteurl = get_site_option( ‘siteurl’ ); if ( $siteurl ) { define( ‘COOKIEHASH’, md5( $siteurl ) ); } This includes the scheme but not a trailing slash, so in your example you’d need the hash of https://zeth.dk. You can also override this by defining COOKIEHASH in … Read more

Is it possible to use cookie-free domains in WordPress?

Earlier it wasn’t possible to use cookie-free domain while using Cloudflare CDN/ Proxy to be exact. Well until yesterday. Cloudflare rolling a new update where they are retiring _cfduid cookie, so your best option will be to wait a few weeks. More details on this- https://blog.cloudflare.com/welcome-to-privacy-and-compliance-week/#improving-the-privacy-of-our-service

Set a cookie only in single posts

init is too early (it happens before the main query), use the action template_redirect instead. And for the ID use get_the_ID(). Example: if ( is_singular() ) setcookie( get_the_ID(), ‘visited’,time() + ( DAY_IN_SECONDS * 31 ) );

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