Skip to main content
deleted 965 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251

Test #1

Test #2

If we want to use the core defined COOKIEHASH constant, then it's too early to hook into muplugins_loaded. We might therefore try the registered_taxonomy hook, but I haven't tested it yet:

add_action( 'registered_taxonomy', function()
{
    if( ! did_action( 'registered_taxonomy' ) && function_exists( 'wpse_cookie_constants' ) )
        wpse_cookie_constants();
});

function wpse_cookie_constants()
{
    if( ! defined( 'COOKIEHASH' ) )
        return;
    
    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'             ); 
}

Test #1

Test #2

If we want to use the core defined COOKIEHASH constant, then it's too early to hook into muplugins_loaded. We might therefore try the registered_taxonomy hook, but I haven't tested it yet:

add_action( 'registered_taxonomy', function()
{
    if( ! did_action( 'registered_taxonomy' ) && function_exists( 'wpse_cookie_constants' ) )
        wpse_cookie_constants();
});

function wpse_cookie_constants()
{
    if( ! defined( 'COOKIEHASH' ) )
        return;
    
    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'             ); 
}
added 659 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251

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.

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

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.

added 659 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251

Check out the wp_cookie_constants() and ms_cookie_constants() functions, to see available cookies.

Test #1

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

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

Test #2

If we want to use the alreadycore defined COOKIEHASH constant, then it's totoo early to hook into muplugins_loaded. We might therefore try the registered_taxonomy hook, but I haven't tested it yet:

add_action( 'registered_taxonomy', function()
{
    if( ! did_action( 'registered_taxonomy' ) && function_exists( 'wpse_cookie_constants' ) )
        wpse_cookie_constants();
});

function wpse_cookie_constants()
{
    if( ! defined( 'COOKIEHASH' ) )
        return;
    
    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'             ); 
}

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

Check out the wp_cookie_constants() and ms_cookie_constants() functions, to see available cookies.

Test #1

We can try this in the wp-config.php file:

define( 'COOKIEHASH',           md5( 'http://example.tld' )    );
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'             );

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

Test #2

If we want to use the already defined COOKIEHASH constant, then it's to early to hook into muplugins_loaded. We might therefore try the registered_taxonomy hook, but I haven't tested it yet:

add_action( 'registered_taxonomy', function()
{
    if( ! did_action( 'registered_taxonomy' ) && function_exists( 'wpse_cookie_constants' ) )
        wpse_cookie_constants();
});

function wpse_cookie_constants()
{
    if( ! defined( 'COOKIEHASH' ) )
        return;
    
    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'             ); 
}

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

Check out the wp_cookie_constants() and ms_cookie_constants() functions, to see available cookies.

Test #1

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

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

Test #2

If we want to use the core defined COOKIEHASH constant, then it's too early to hook into muplugins_loaded. We might therefore try the registered_taxonomy hook, but I haven't tested it yet:

add_action( 'registered_taxonomy', function()
{
    if( ! did_action( 'registered_taxonomy' ) && function_exists( 'wpse_cookie_constants' ) )
        wpse_cookie_constants();
});

function wpse_cookie_constants()
{
    if( ! defined( 'COOKIEHASH' ) )
        return;
    
    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'             ); 
}

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

added 659 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251
Loading
added 1639 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251
Loading
added 1639 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251
Loading
added 51 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251
Loading
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251
Loading