How to change cookie name

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_’ . COOKIEHASH ); define( ‘PASS_COOKIE’, ‘wpse_pass_’ . COOKIEHASH ); … Read more

Extending auth_cookie_expiration based on user role

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( ‘auth_cookie_expiration’,’wpse108399_change_cookie_logout’, 10, 3 );

COOKIE_DOMAIN setting confusion

As cdn.mydomain.com is not part of your WordPress network, it wont be affected by your settings. The COOKIE_DOMAIN constant should only be used if you want to serve cookies from a single domain for all your sites in the network. If you omit the constant or set it to an empty value, cookies will belong … Read more

How to detect a user that is not logged in

You could check for this cookie wp-settings-1 it lasts for 1 day and then also check if wordpress_test_cookie is available. Or you could just write a simple plugin that checks if the user is logged in and adds a longer term cookie to check against.

How to Create a Cookieless Domain in WordPress

Using “cookieless” domain for serving static assets is common recommendation performance tools give. The reasoning being that cookies do nothing at all for such files, but still consume resources. It is, however, not something WP can handle for following reasons: WordPress does not control domain. DNS points domain to specific server’s IP address, where WP … Read more

Disable saving comment details (name, e-mail) in cookie?

That is actually dead simple. Cookies are set by wp_set_comment_cookies() and this function is hooked into ‘set_comment_cookies’. Just remove the function from the action: <?php # -*- coding: utf-8 -*- /* Plugin Name: No Comment Cookies */ remove_action( ‘set_comment_cookies’, ‘wp_set_comment_cookies’ ); Download on GitHub.

Place a cookie when a specific page has been viewed?

I’ve worked out a solution. There may be a more elegant way to achieve this, but I had trouble getting anything else to work. I’ve placed the following code at the beginning of the header.php file for all pages. The objective is to funnel site visitors through an event registration page, prior to accessing the … Read more

Keep one user logged for a year?

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 have your filter … Read more

Remember the last post I read

I like this question so had a look at it myself. The best way I could think to go about it would be to use localstorage and jQuery to store the current URL and scroll position of the user. Then you could either run a check when they come back to that page or have … Read more

How to set custom cookies before output

Depends on whether or not you need to check against WordPress’ user authentication. If you need to know whether they’re a logged in user, hook onto ‘init’. Otherwise, the sooner the better. If it’s something that should fire on every page load, and only checks for existence of the cookie and doesn’t need to tap … Read more

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