We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

5

When you log in to the admin WordPress sets cookies (in PHP) to keep you logged in while you navigate around your site. If this fails, you get the error message, "Cookies are blocked or not supported by your browser." This could fail in a couple different ways, but before we dig into those situations, let's take a look at the source of these error messages:...


3

The problem is that you're not using the correct name for the REST API nonce header — the correct name is X-WP-Nonce, but you used X-WP-Header: fetch('http://localhost/wptest2/?rest_route=/wp/v2/users/me', { method : 'get', mode : 'cors', headers : { 'Access-Control-Allow-Origin' : '*', 'X-WP-Header' : _wpnonce // here you used the wrong ...


3

It’s a problem as old as WP, or even older... You can’t set cookies, or send any other headers, if any of the content of the site is already sent. You try to set cookies using init hook. And it is OK in most cases, since no output should be printed yet. But... Not all code is written correctly. There are many other thing done before init. Take a look at ...


2

Can they for example simply copy the cookie and "be" logged in as the user who was the original cookie owner? Yes! with the cookie they basically have your login session. You do not want 3rd parties to get the cookie. Keep in mind there is more than 1 cookie, for frontend and for backend. I ask this because i'm planning on passing the auth cookie value ...


2

For remote apps (cURL, Postman, etc.), or when not using the browser, you should use an authentication plugin like Application Passwords instead of sending the cookies. But if you'd rather send the cookies, then copy and send the WordPress logged-in cookie named wordpress_logged_in_<hash>. Example in cURL: curl -H "X-WP-Nonce: <nonce>" -X POST ...


1

I read the other question to better understand what you intend on doing. The first thing you need to understand is that there are many ways cookies can be sent and without knowing any details of your hosting environment, of what you have control over, it is impossible to state, specifically, what you need to do. So, that said, here are some things you can ...


1

This was caused simply by the salts in wp-config.php being at the end of the file, after the call to wp-settings.php (they were inserted by an Ansible script) rather than above the line: /* That's all, stop editing! Happy publishing. */ :(


1

Solved : WP Engine :rolleyes - When using WPEngine you have to ask them to manually exempt whatever cookies you set otherwise the caching they use will essentially render an empty string and make it look like the cookie wasn't set


1

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 = '/'; $cookie->domain = '.reddit.com'; $cookies[] = $cookie; $url = '...


1

I've used this and it works: add_action('init', 'optin_cookie', 1); function optin_cookie(){ $currentURL = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if ( $currentURL == 'https://25dni.si/delovanje-uma/' ) : setcookie( 'opt_in', has_opt_in, time()+31556926, '/'); elseif ( $currentURL != 'https://25dni.si/' ) : if ...


1

The second parameter in add_filter is a function with accepted arguments, not returned values. This is an example how I pass my custom array $args to change an existing array $filter_args: add_filter( 'woocommerce_dropdown_variation_attribute_options_args', function( $filter_args ) use ( $args ) { return eswc_var_dropdown_args( $filter_args, $args )...


Only top voted, non community-wiki answers of a minimum length are eligible