Title: wp_cookie_constants
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_cookie_constants()

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_cookie_constants/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/functions/wp_cookie_constants/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_cookie_constants/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_cookie_constants/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_cookie_constants/?output_format=md#wp--skip-link--target)

Defines cookie-related WordPress constants.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_cookie_constants/?output_format=md#description)󠁿

Defines constants after multisite is loaded.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_cookie_constants/?output_format=md#source)󠁿

    ```php
    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
    	 * @since 6.6.0 The value has changed from false to an empty string.
    	 */
    	if ( ! defined( 'COOKIE_DOMAIN' ) ) {
    		define( 'COOKIE_DOMAIN', '' );
    	}

    	if ( ! defined( 'RECOVERY_MODE_COOKIE' ) ) {
    		/**
    		 * @since 5.2.0
    		 */
    		define( 'RECOVERY_MODE_COOKIE', 'wordpress_rec_' . COOKIEHASH );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/default-constants.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/default-constants.php#L243)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/default-constants.php#L243-L342)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_cookie_constants/?output_format=md#related)󠁿

| Uses | Description | 
| [get_site_option()](https://developer.wordpress.org/reference/functions/get_site_option/)`wp-includes/option.php` |

Retrieve an option value for the current network based on name of option.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_cookie_constants/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_cookie_constants%2F)
before being able to contribute a note or feedback.