Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Hot answers tagged

26

Add below line to your wp-config.php before /* That's all, stop editing!...*/ define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] ); /* That's all, stop editing! Happy blogging. */


17

1 - You can check for cookies and do your redirect using hooks that are called before any output like the 'init' hook: <?php // Hook the function "redirect()" on to the "init" action add_action('init', 'redirect'); // redirect() may redirect the user depending on the cookies he has function redirect(){ /* CODE */ } ?> 2 - The best way to set ...


11

You probably should use the constants COOIKEPATH and COOKIE_DOMAIN, existing since WP 3.0 setcookie("your_cookie", $your_value, time()+3600, COOKIEPATH, COOKIE_DOMAIN);


10

Short introduction After quick look inside WP source code, I think I've found solution... WordPress uses two functions to set and parse auth cookies: wp_generate_auth_cookie wp_parse_auth_cookie There is a filter in wp_generate_auth_cookie called auth_cookie which you probably could use to change the contents of cookie, but there is no filter inside ...


8

Untested, but the following should only change the expiration time for admins who select 'remember me'. function wpse108399_change_cookie_logout( $expiration, $user_id, $remember ){ if( $remember && user_can( $user_id, 'manage_options' ) ){ $expiration = 60;// yes, I know this is 1 minute } return $expiration; } add_filter( '...


7

WordPress already has an API built in via an XMLRPC server. Meaning, you can make an XMLRPC request from your java app and verify a username/password. Unfortunately, there's no way to just authenticate through it as is. That said, it's very easy to roll your own. Just hook into xmlrpc_methods, a filter, and add yours. The array key you add with be the ...


6

The cookie looks like it is being set by the PHP session handling process. WordPress 'out of the box' doesn't use sessions, which would seem to point towards either your theme or a plugin. If you search your code base for 'session_start' you may be able to track down where the session is being initiated. PHP can also be set to auto start sessions. You ...


6

This error is generated in wp-login.php , it happens if server is unable to set cookies, this can happen due to several reasons, one of the common issue is: output being sent before setting up of cookies. Try out following options: Update WordPress core, if it is not up to date change theme, if you are using custom theme, just ftp into server and delete ...


5

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'];


5

I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user's cookies to retrieve preview page source: $preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) ); $...


5

Here (with some trepidation) is a sketch of a use-once link solution that might be safeish enough if one can depend on the ip being fairly constant (at least in the short-term) to the phone, using a query var and a transient based on $_SERVER['REMOTE_ADDR'], though as @Wyck and @G. M. say, any such backdoor is a security risk... // Make query var & ...


5

wp_login hook provides access to two parameters: $user->user_login (string) and $user ( WP_User ). To pass them into your function you will need to add a priority (default is 10) and request 2 arguments from the add_action() call: function login_cookie($user_login, $user) { global $wpdb; var_dump($user); // get WP_User object //Get current ...


5

Check out the wp_cookie_constants() and ms_cookie_constants() functions, to see available cookies. We can try this in the wp-config.php file: // Here we just simulate how it's done in the core define( 'COOKIEHASH', md5( 'http://example.tld' ) ); // Then we override the cookie names: define( 'USER_COOKIE', 'wpse_user_' . ...


5

You can follow these steps written below: Rename themes directory and plugins directory. Now visit /wp-admin/ or /wp-login.php. I hope this time it would work. If step 2 works, then login to the dashboard. Now, Rename themes directory again into themes Then, visit Appearance menu and activate any default wordpress theme. I hope, this point you can access ...


5

I have been struggling with using the multisite domains of native 4.x wordpress. Despite finding references, saying these lines corrected the error, neither of these setting worked: //define('COOKIE_DOMAIN', false); //define( ‘COOKIE_DOMAIN’, $_SERVER[ ‘HTTP_HOST’ ] ); In the end, I added the following lines of code instead, and it worked marvellously... ...


5

It looks like you're missing the nonce part, as explained in the Authentication chapter, in the REST API Handbook: Cookie authentication is the basic authentication method included with WordPress. When you log in to your dashboard, this sets up the cookies correctly for you, so plugin and theme developers need only to have a logged-in user. ...


5

You won't be able to log in to WordPress at all without cookies. It's not just about remembering if you're logged in the next day, it's about remembering if you're logged in every time you go to a different page in the admin. The only cookies WordPress adds itself (so not counting plugins) are for logging in and for commenting. You only need the login ones ...


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:...


4

"On login, wordpress uses the wordpress_[hash] cookie to store your authentication details. It's use is limited to the admin console area, /wp-admin/ After login, wordpress sets the wordpress_logged_in_[hash] cookie, which indicates when you're logged in, and who you are, for most interface use. Wordpress also sets a few wp-settings-{time}-[UID] cookies. ...


4

If you don't give the cookie an expires time it will only be available during that session. You will also need to destroy an existing cookie if it is already set. jQuery(function() { jQuery('#categoriesform').submit(function(e) { if (jQuery.cookie('my_cookie') ) { jQuery.cookie( 'my_cookie', null) } jQuery.cookie('my_cookie', '...


4

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.


4

In W3TC you can specify files or cookies that are ignored and not cached. Exclude Files from Cache To do this go to WordPress Admin > Performance > Page Cache In the screenshot ... you will see I've added custom sidebars from a Twenty-Eleven theme. These are excluded from being cached. You can also specify your custom cookie to not be cached ... ...


4

The cookies are fine. The secret is caching. The blog owner has set up a server side output caching that doesn’t stop when someone sends as cookie. It should – as you can see, because caching pages with personal data is … odd. Lesson: Don’t cache personalized output.


4

using wp-login.php as a template. is not a correct way to do that. Source You'd better use the wp_login_form() function in a custom template. EDIT: And if you want to add an option to reset password you could do this : add_action( 'login_form_middle', 'add_lost_password_link' ); function add_lost_password_link() { return '<a href="/wp-login.php?...


4

Why are you building a seperate user system in the first place? The wordpress builtin system is pretty flexible. In theory all the login functions like wp_set_auth_cookie(), wp_generate_auth_cookie(), wp_parse_auth_cookie() etc. are all pluggable functions. Which means you can replace them with your own custom functions. But to be realistic, it will be a ...


4

if you are logged in wp_parse_auth_cookie(LOGGED_IN_COOKIE); will return array consisting wp user name, cookie hash and expiration time. This function will return null if you are not logged in. But you cannot get plain password as wordpress doesn't store plain password.


4

It turns out I had DOMAIN_CURRENT_SITE set incorrectly in wp-config.php. (This particular install was a copy of another server, and the domain hadn't fully been changed.)


4

Basically, they're hashing salts. They're used to make the results of hashing much less predictable. See https://en.wikipedia.org/wiki/Salt_(cryptography) for info on salts. AUTH is used for the /wp-admin authentication cookie, SECURE_AUTH is for the same when using SSL, LOGGED_IN is used for identification to the "front-end" of the site. NONCE is used for ...


4

Change this line setcookie( 'cookiename', 'cookievalue', time() + 3600, 'mysite.net/sites/site1/', 'mysite.net/sites/site1/'); to setcookie( 'cookiename', cookievalue, time() + 3600, COOKIEPATH, COOKIE_DOMAIN);` COOKIEPATH and COOKIE_DOMAIN are WP constants now, but the codex is not updated yet.


4

get_currentuserinfo() is a pluggable function, it is not available during plugins load stage. That aside you shouldn't be adding filter conditionally, but use data provided by the filter. If you take a look at filter calls: apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember ) $user_id is provided as second argument. You just ...


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