Why can’t I enter the wordpress admin interface?

The error message you see points to this part within the wp-login.php file: setcookie( TEST_COOKIE, ‘WP Cookie check’, 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); to its “path”, which is the 4th parameter: SITECOOKIEPATH If you check how that constant is defined, that is: define( ‘SITECOOKIEPATH’, preg_replace( ‘|https?://[^/]+|i’, ”, get_option( ‘siteurl’ ) . “https://wordpress.stackexchange.com/” ) ); meaning … Read more

PHP cookie not set within AJAX call

Apparently I was missing the time() attribute. So when adding this to the expire option in the setCookie function, the cookie is being set. Code: setcookie(‘user-zipcode’, $zipcode, time() + MONTH_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN); setcookie(‘delivery-today’, $cookieVal, time() + DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);

Why can’t I enter the wordpress admin interface?

The error message you see points to this part within the wp-login.php file: setcookie( TEST_COOKIE, ‘WP Cookie check’, 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); to its “path”, which is the 4th parameter: SITECOOKIEPATH If you check how that constant is defined, that is: define( ‘SITECOOKIEPATH’, preg_replace( ‘|https?://[^/]+|i’, ”, get_option( ‘siteurl’ ) . “https://wordpress.stackexchange.com/” ) ); meaning … Read more

Cookies in Multisite network where sites have their own domain name?

First clear your browser’s cache (including cookies) and your server’s cache (cache plugins, etc.) Then set the following in your wp-config.php file: define(‘ADMIN_COOKIE_PATH’, “https://wordpress.stackexchange.com/”); define(‘COOKIE_DOMAIN’, ”); define(‘COOKIEPATH’, ”); define(‘SITECOOKIEPATH’, ”); Also, you may checkout the answer from HERE: define(‘WP_ALLOW_MULTISITE’, true); define(‘MULTISITE’, true); define(‘SUBDOMAIN_INSTALL’, false); define(‘DOMAIN_CURRENT_SITE’, ‘your-domain.example’); define(‘PATH_CURRENT_SITE’, “https://wordpress.stackexchange.com/”); define(‘SITE_ID_CURRENT_SITE’, 1); define(‘BLOG_ID_CURRENT_SITE’, 1); define(‘SUNRISE’, ‘on’); If … Read more

Modify the third (context) parameter in a filter?

You can’t modify the parameters of a filter like that, that’s not what they’re there for. In the source code it’ll look something like this: $cookie = apply_filters( $cookie, $user_id, $expiration, $scheme, $token ); It’s explicitly looking for the value of $cookie. If you return the value for $expiration, things will break. The extra parameters … Read more

How to delete Password Protected posts cookies when a user logged out from the site

The post password cookie is set with: setcookie( ‘wp-postpass_’ . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST[‘post_password’] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); in the wp-login.php file. We can then use the clear_auth_cookie hook, in the wp_clear_auth_cookie() function, to clear it on logout: /** * Clear the Post Password Cookie on logout. * * @link http://wordpress.stackexchange.com/a/198890/26350 */ … Read more

Is it possible to tell if a user is logged into WordPress from looking at the cookies which are set?

You could use Javascript <script type=”text/javascript”> function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(“;”); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf(“=”)); y=ARRcookies[i].substr(ARRcookies[i].indexOf(“=”)+1); x=x.replace(/^\s+|\s+$/g,””); if (x==c_name) { return unescape(y); } } } var logged_in=getCookie(“wordpress_logged_in_[HASH]”); if (logged_in!=null && logged_in!=””) { alert(“You are logged in!”); } else { alert(“You are logged out!”); } </script> NOTE: WordPress logged in cookie info can be found here. … Read more