How Do I Create a Custom Cookie in WordPress?

Creating a custom cookie in WordPress is simple. You will need to first create a new file in your WordPress theme directory and name it cookies.

php. Within this file, you will need to include the following code:.

Next, you will need to create a custom-cookie.php file within your custom theme directory and include the following code:

/**

* Custom Cookie Script

*

* @name custom-cookie

*/

define( ‘WP_COOKIE_NAME’, ‘custom-cookie’);

* Register Custom Cookie

* @return bool

function custom_cookie() {

wp_enqueue_script( WP_COOKIE_NAME, get_template_directory_uri() .php’);

return true;

}

Now, you will need to add the following line to your wp-config.php file:

Finally, you will need to create a custom-cookie.php file in your theme directory and include the following code:.