Im trying to figure out how can I change names to cookies that wordpress is setting for example on login.

wordpress_test_cookie = sitename_test_cookie

or/ and

 wordpress_logged_in = sitename_test_cookie

2 Answers
2

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 );
define( 'AUTH_COOKIE',          'wpse_'           . COOKIEHASH );
define( 'SECURE_AUTH_COOKIE',   'wpse_sec_'       . COOKIEHASH );
define( 'LOGGED_IN_COOKIE',     'wpse_logged_in_' . COOKIEHASH );
define( 'TEST_COOKIE',          'wpse_test_cookie'             );

or using PHP 5.6+ :

// Then we override the cookie names:
const USER_COOKIE        = 'wpse_user_'      . COOKIEHASH;
const PASS_COOKIE        = 'wpse_pass_'      . COOKIEHASH;
const AUTH_COOKIE        = 'wpse_'           . COOKIEHASH;
const SECURE_AUTH_COOKIE = 'wpse_sec_'       . COOKIEHASH;
const LOGGED_IN_COOKIE   = 'wpse_logged_in_' . COOKIEHASH;
const TEST_COOKIE        = 'wpse_test_cookie';

where we must adjust the site url http://example.tld to our needs.

But I also wonder, as @PieterGoosen, why you need to change it.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *