wp_cookie_constants

The timeline below displays how wordpress function wp_cookie_constants has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.4

/**
 * Defines cookie-related WordPress constants.
 *
 * Defines constants after multisite is loaded.
 *
 * @since 3.0.0
 */
function wp_cookie_constants()
{
    /**
     * Used to guarantee unique hash cookies.
     *
     * @since 1.5.0
     */
    if (!defined('COOKIEHASH')) {
        $siteurl = get_site_option('siteurl');
        if ($siteurl) {
            define('COOKIEHASH', md5($siteurl));
        } else {
            define('COOKIEHASH', '');
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('USER_COOKIE')) {
        define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
    }
    /**
     * @since 2.0.0
     */
    if (!defined('PASS_COOKIE')) {
        define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
    }
    /**
     * @since 2.5.0
     */
    if (!defined('AUTH_COOKIE')) {
        define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('SECURE_AUTH_COOKIE')) {
        define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('LOGGED_IN_COOKIE')) {
        define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
    }
    /**
     * @since 2.3.0
     */
    if (!defined('TEST_COOKIE')) {
        define('TEST_COOKIE', 'wordpress_test_cookie');
    }
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/'));
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/'));
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
    }
    /**
     * @since 2.6.0
     */
    if (!defined('PLUGINS_COOKIE_PATH')) {
        define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL));
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN')) {
        define('COOKIE_DOMAIN', false);
    }
    if (!defined('RECOVERY_MODE_COOKIE')) {
        /**
         * @since 5.2.0
         */
        define('RECOVERY_MODE_COOKIE', 'wordpress_rec_' . COOKIEHASH);
    }
}

WordPress Version: 5.2

/**
 * Defines cookie related WordPress constants
 *
 * Defines constants after multisite is loaded.
 *
 * @since 3.0.0
 */
function wp_cookie_constants()
{
    /**
     * Used to guarantee unique hash cookies
     *
     * @since 1.5.0
     */
    if (!defined('COOKIEHASH')) {
        $siteurl = get_site_option('siteurl');
        if ($siteurl) {
            define('COOKIEHASH', md5($siteurl));
        } else {
            define('COOKIEHASH', '');
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('USER_COOKIE')) {
        define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
    }
    /**
     * @since 2.0.0
     */
    if (!defined('PASS_COOKIE')) {
        define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
    }
    /**
     * @since 2.5.0
     */
    if (!defined('AUTH_COOKIE')) {
        define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('SECURE_AUTH_COOKIE')) {
        define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('LOGGED_IN_COOKIE')) {
        define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
    }
    /**
     * @since 2.3.0
     */
    if (!defined('TEST_COOKIE')) {
        define('TEST_COOKIE', 'wordpress_test_cookie');
    }
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/'));
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/'));
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
    }
    /**
     * @since 2.6.0
     */
    if (!defined('PLUGINS_COOKIE_PATH')) {
        define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL));
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN')) {
        define('COOKIE_DOMAIN', false);
    }
    if (!defined('RECOVERY_MODE_COOKIE')) {
        /**
         * @since 5.2.0
         */
        define('RECOVERY_MODE_COOKIE', 'wordpress_rec_' . COOKIEHASH);
    }
}

WordPress Version: 5.1

/**
 * Defines cookie related WordPress constants
 *
 * Defines constants after multisite is loaded.
 *
 * @since 3.0.0
 */
function wp_cookie_constants()
{
    /**
     * Used to guarantee unique hash cookies
     *
     * @since 1.5.0
     */
    if (!defined('COOKIEHASH')) {
        $siteurl = get_site_option('siteurl');
        if ($siteurl) {
            define('COOKIEHASH', md5($siteurl));
        } else {
            define('COOKIEHASH', '');
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('USER_COOKIE')) {
        define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
    }
    /**
     * @since 2.0.0
     */
    if (!defined('PASS_COOKIE')) {
        define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
    }
    /**
     * @since 2.5.0
     */
    if (!defined('AUTH_COOKIE')) {
        define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('SECURE_AUTH_COOKIE')) {
        define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('LOGGED_IN_COOKIE')) {
        define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
    }
    /**
     * @since 2.3.0
     */
    if (!defined('TEST_COOKIE')) {
        define('TEST_COOKIE', 'wordpress_test_cookie');
    }
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/'));
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/'));
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
    }
    /**
     * @since 2.6.0
     */
    if (!defined('PLUGINS_COOKIE_PATH')) {
        define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL));
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN')) {
        define('COOKIE_DOMAIN', false);
    }
}

WordPress Version: 4.8

/**
 * Defines cookie related WordPress constants
 *
 * Defines constants after multisite is loaded.
 * @since 3.0.0
 */
function wp_cookie_constants()
{
    /**
     * Used to guarantee unique hash cookies
     *
     * @since 1.5.0
     */
    if (!defined('COOKIEHASH')) {
        $siteurl = get_site_option('siteurl');
        if ($siteurl) {
            define('COOKIEHASH', md5($siteurl));
        } else {
            define('COOKIEHASH', '');
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('USER_COOKIE')) {
        define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
    }
    /**
     * @since 2.0.0
     */
    if (!defined('PASS_COOKIE')) {
        define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
    }
    /**
     * @since 2.5.0
     */
    if (!defined('AUTH_COOKIE')) {
        define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('SECURE_AUTH_COOKIE')) {
        define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('LOGGED_IN_COOKIE')) {
        define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
    }
    /**
     * @since 2.3.0
     */
    if (!defined('TEST_COOKIE')) {
        define('TEST_COOKIE', 'wordpress_test_cookie');
    }
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/'));
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/'));
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
    }
    /**
     * @since 2.6.0
     */
    if (!defined('PLUGINS_COOKIE_PATH')) {
        define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL));
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN')) {
        define('COOKIE_DOMAIN', false);
    }
}

WordPress Version: 4.7

/**
 * Defines cookie related WordPress constants
 *
 * Defines constants after multisite is loaded.
 * @since 3.0.0
 */
function wp_cookie_constants()
{
    /**
     * Used to guarantee unique hash cookies
     *
     * @since 1.5.0
     */
    if (!defined('COOKIEHASH')) {
        $siteurl = get_site_option('siteurl');
        if ($siteurl) {
            define('COOKIEHASH', md5($siteurl));
        } else {
            define('COOKIEHASH', md5(wp_guess_url()));
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('USER_COOKIE')) {
        define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
    }
    /**
     * @since 2.0.0
     */
    if (!defined('PASS_COOKIE')) {
        define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
    }
    /**
     * @since 2.5.0
     */
    if (!defined('AUTH_COOKIE')) {
        define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('SECURE_AUTH_COOKIE')) {
        define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('LOGGED_IN_COOKIE')) {
        define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
    }
    /**
     * @since 2.3.0
     */
    if (!defined('TEST_COOKIE')) {
        define('TEST_COOKIE', 'wordpress_test_cookie');
    }
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/'));
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/'));
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
    }
    /**
     * @since 2.6.0
     */
    if (!defined('PLUGINS_COOKIE_PATH')) {
        define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL));
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN')) {
        define('COOKIE_DOMAIN', false);
    }
}

WordPress Version: 4.2

/**
 * Defines cookie related WordPress constants
 *
 * Defines constants after multisite is loaded.
 * @since 3.0.0
 */
function wp_cookie_constants()
{
    /**
     * Used to guarantee unique hash cookies
     *
     * @since 1.5.0
     */
    if (!defined('COOKIEHASH')) {
        $siteurl = get_site_option('siteurl');
        if ($siteurl) {
            define('COOKIEHASH', md5($siteurl));
        } else {
            define('COOKIEHASH', '');
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('USER_COOKIE')) {
        define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
    }
    /**
     * @since 2.0.0
     */
    if (!defined('PASS_COOKIE')) {
        define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
    }
    /**
     * @since 2.5.0
     */
    if (!defined('AUTH_COOKIE')) {
        define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('SECURE_AUTH_COOKIE')) {
        define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('LOGGED_IN_COOKIE')) {
        define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
    }
    /**
     * @since 2.3.0
     */
    if (!defined('TEST_COOKIE')) {
        define('TEST_COOKIE', 'wordpress_test_cookie');
    }
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/'));
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/'));
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
    }
    /**
     * @since 2.6.0
     */
    if (!defined('PLUGINS_COOKIE_PATH')) {
        define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL));
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN')) {
        define('COOKIE_DOMAIN', false);
    }
}

WordPress Version: 3.9

/**
 * Defines cookie related WordPress constants
 *
 * Defines constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
 * @since 3.0.0
 */
function wp_cookie_constants()
{
    /**
     * Used to guarantee unique hash cookies
     *
     * @since 1.5.0
     */
    if (!defined('COOKIEHASH')) {
        $siteurl = get_site_option('siteurl');
        if ($siteurl) {
            define('COOKIEHASH', md5($siteurl));
        } else {
            define('COOKIEHASH', '');
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('USER_COOKIE')) {
        define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
    }
    /**
     * @since 2.0.0
     */
    if (!defined('PASS_COOKIE')) {
        define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
    }
    /**
     * @since 2.5.0
     */
    if (!defined('AUTH_COOKIE')) {
        define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('SECURE_AUTH_COOKIE')) {
        define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('LOGGED_IN_COOKIE')) {
        define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
    }
    /**
     * @since 2.3.0
     */
    if (!defined('TEST_COOKIE')) {
        define('TEST_COOKIE', 'wordpress_test_cookie');
    }
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/'));
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/'));
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
    }
    /**
     * @since 2.6.0
     */
    if (!defined('PLUGINS_COOKIE_PATH')) {
        define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL));
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN')) {
        define('COOKIE_DOMAIN', false);
    }
}

WordPress Version: 3.7

/**
 * Defines cookie related WordPress constants
 *
 * Defines constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
 * @since 3.0.0
 */
function wp_cookie_constants()
{
    /**
     * Used to guarantee unique hash cookies
     * @since 1.5
     */
    if (!defined('COOKIEHASH')) {
        $siteurl = get_site_option('siteurl');
        if ($siteurl) {
            define('COOKIEHASH', md5($siteurl));
        } else {
            define('COOKIEHASH', '');
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('USER_COOKIE')) {
        define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
    }
    /**
     * @since 2.0.0
     */
    if (!defined('PASS_COOKIE')) {
        define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
    }
    /**
     * @since 2.5.0
     */
    if (!defined('AUTH_COOKIE')) {
        define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('SECURE_AUTH_COOKIE')) {
        define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('LOGGED_IN_COOKIE')) {
        define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
    }
    /**
     * @since 2.3.0
     */
    if (!defined('TEST_COOKIE')) {
        define('TEST_COOKIE', 'wordpress_test_cookie');
    }
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/'));
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/'));
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
    }
    /**
     * @since 2.6.0
     */
    if (!defined('PLUGINS_COOKIE_PATH')) {
        define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL));
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN')) {
        define('COOKIE_DOMAIN', false);
    }
}